<template>
  <div class="hrManagementBox page_set page-miH page-bgBack">
    <div class="headerBox">
      <div
        class="headerBoxItem"
        v-for="item in tabList"
        :key="item.id"
        @click="tapChange(item.id)"
        :class="item.id === selectId ? 'backF4F' : ''"
      >
        <div class="headerBoxItemHei26">
          <div class="headerBoxItemHeiBox">
            <img class="headerBoxItemHeiImg" :src="item.img" alt />
            <div>
              <div class="cola6a">{{ item.title }}</div>
              <div class="col55565D">{{ item.count }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div>
      <div class="button-group" style="margin-top: 24px">
        <div class="ml12 mr12" style="display: inline-block; width: 180px">
          <a-input-search
            id="nameOrPhone"
            v-model="searchForm.nameOrPhone"
            placeholder="姓名/手机号/身份证号"
            style="width: 180px"
            :defaultValue="searchForm.nameOrPhone"
            @blur="select"
            @keyup.enter.native="select"
          />
        </div>
        <a-select
          v-if="selectId === '1'"
          title
          style="min-width: 130px; width: 130px; margin-right: 12px"
          placeholder="选择人员状态"
          allow-clear
          @change="handleProgName2"
          :defaultValue="searchForm.approvalAndStatus"
        >
          <a-select-option v-for="item in liststatus" :key="item.id" style>{{ item.value }}</a-select-option>
        </a-select>
        <!--1 时间 入职登记表 onTimeChange  handleTableFormChange-->
        <a-range-picker
          v-if="selectId === '1'"
          v-model="searchForm.preJoinDateMoment"
          :placeholder="['入职开始时间', '入职结束时间']"
          class="mr12"
          @change="search"
          :defaultValue="searchForm.preJoinDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>
        <a-range-picker
          v-if="selectId === '2'"
          v-model="searchForm.turnStraightDateMoment"
          :placeholder="['预计转正开始时间', '预计转正结束时间']"
          style="margin-left: 12px"
          @change="search"
          :defaultValue="searchForm.turnStraightDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>

        <!--3 入职时间 -->
        <!-- 转正时间 -->

        <a-range-picker
          v-if="selectId === '3'"
          v-model="searchForm.joinDateMoment"
          :placeholder="['入职开始时间', '入职结束时间']"
          class="mr12"
          @change="search"
          :defaultValue="searchForm.joinDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>
        <a-range-picker
          v-if="selectId === '3'"
          v-model="searchForm.turnStraightDateMoment"
          :placeholder="['预计转正开始时间', '预计转正结束时间']"
          @change="search"
          :defaultValue="searchForm.turnStraightDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>

        <a-range-picker
          v-if="selectId === '4'"
          v-model="searchForm.leaveDateMoment"
          :placeholder="['离职开始时间', '离职结束时间']"
          style="margin-left: 12px"
          @change="search"
          :defaultValue="searchForm.leaveDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>

        <!--5 申请调岗时间 -->
        <a-range-picker
          v-if="selectId === '5'"
          v-model="searchForm.transferDateMoment"
          :placeholder="['调岗开始时间', '调岗结束时间']"
          @change="search"
          :defaultValue="searchForm.transferDateMoment"
        >
          <a-icon slot="suffixIcon" type="clock-circle" />
        </a-range-picker>
        <a-button v-if="selectId === '1'" class="fr mr12" @click="addMember" type="primary" icon="plus">添加待入职</a-button>
        <a-button v-if="selectId === '1'" class="fr mr12" type="primary" ghost @click="openEmployeesMove('批量到岗')">批量到岗</a-button>
        <a-button v-if="selectId === '1'" type="primary" ghost class="fr mr12" @click="openEmployeesMove('批量未到岗')"
          >批量未到岗</a-button
        >

        <a-button v-if="selectId === '2'" type="primary" class="fr mr12" @click="openEmployeesMove('批量离职')">批量离职</a-button>
        <a-button v-if="selectId === '2'" class="fr mr12" type="primary" @click="openEmployeesMove('批量转正')">批量转正</a-button>
        <a-dropdown v-if="selectId === '4'" class="fr" style="width: 110px" type="primary" ghost>
          <a-menu slot="overlay" @click="handleChangeStaff">
            <a-menu-item key="namePinyin">发起离职合同</a-menu-item>
            <a-menu-item key="gmtCreate">导入Excel办理</a-menu-item>
            <a-menu-item key="gmtModified">已离职记录</a-menu-item>
          </a-menu>
          <a-button>
            更多功能
            <a-icon type="down" />
          </a-button>
        </a-dropdown>
        <a-button v-if="selectId === '3'" class="fr mr12" type="primary" @click="openEmployeesMove('批量调岗')">批量调岗</a-button>
        <a-button v-if="selectId === '3'" class="fr mr12" type="primary" @click="merberBatchLZ('批量离职')">批量离职</a-button>
        <a-button v-if="selectId === '4'" class="fr mr12" type="primary" icon="plus" @click="merberLeave">办理离职</a-button>
        <a-button v-if="selectId === '4'" class="fr mr12" type="primary" @click="batchLeave('批量确认离职')">批量确认离职</a-button>
        <a-button v-if="selectId === '4'" class="fr mr12" @click="openEmployeesMove('批量撤销离职')">批量撤销离职</a-button>

        <a-button v-if="selectId === '5'" class="fr" @click="goto('moveTag')">已调岗记录</a-button>
        <a-button v-if="selectId === '5'" class="fr mr12" type="primary" icon="plus" @click="goto('visibleMoveDrawer')">办理调岗</a-button>
        <a-button v-if="selectId === '5'" class="fr mr12" type="primary" @click="openEmployeesMove('批量确认调岗')">批量确认调岗</a-button>
        <a-button v-if="selectId === '5'" class="fr mr12" @click="openEmployeesMove('批量撤销调岗')">批量撤销调岗</a-button>
      </div>
      <a-modal
        :title="isBatchLeaveConfirm ? '批量确认离职' : '确认离职'"
        :visible="isCloseMethod"
        width="620px"
        :destroy-on-close="true"
        @cancel="handleCancel"
      >
        <template slot="footer">
          <a-button @click="handleCancel">取消</a-button>
          <a-button key="submit" type="primary" @click="finishEdit">确定</a-button>
        </template>

        <div style="padding: 0 56px">
          <a-form :label-col="{ span: 9 }" :wrapper-col="{ span: 16 }">
            <a-form-item class="baseInfo-item" label="姓名">
              <span v-if="isBatchLeaveConfirm" style="margin-left: 10px">{{ formatLeaveEmyListNames(leaveEmyList) }}</span>
              <span v-else style="margin-left: 10px">{{ leaveEmy ? leaveEmy.name : "" }}</span>
            </a-form-item>
            <a-form-item class="baseInfo-item" label="确认离职日期">
              <a-date-picker
                v-if="isBatchLeaveConfirm"
                :default-value="batchPreQuitDate"
                style="margin-left: 10px"
                @change="onLeaveChange"
                :allowClear="false"
                :disabled-date="disabledDateRegularDate"
              />
              <a-date-picker
                v-else
                :default-value="leaveEmy ? (leaveEmy.preQuitDate ? moment(leaveEmy.preQuitDate).format(leaveFormat) : null) : null"
                style="margin-left: 10px"
                @change="onLeaveChange"
                :allowClear="false"
                :disabled-date="disabledDateRegularDate"
              />
            </a-form-item>
            <a-form-item v-if="!isBatchLeaveConfirm" class="baseInfo-item" label="是否发起离职合同">
              <a-switch style="margin-left: 10px" :default-checked="isHeTong" @change="onHtChange" />
            </a-form-item>
            <a-form-item class="baseInfo-item" label="是否进行社保减员">
              <a-switch v-if="hasShebao" style="margin-left: 10px" :default-checked="isShebaoJianYuan" @change="onJYChange" />
              <div v-if="!hasShebao" class="rowdialog">
                <img style="width: 14px; height: 14px; margin-left: 10px" src="@/assets/img/tanhao.png" />
                <div style="color: #a6a8b4; font-size: 14px; margin-left: 5px">员工未缴纳社保</div>
              </div>
            </a-form-item>
            <a-form-item v-if="hasShebao && isShebaoJianYuan" class="baseInfo-item" label="社保停保起始年月">
              <a-month-picker
                :default-value="moment(shebaoDate, monthFormat)"
                style="margin-left: 10px"
                @change="onYearMonthChange_SB"
                :allowClear="false"
                :disabled-date="disabledDate2"
              />
            </a-form-item>
            <a-form-item class="baseInfo-item" label="是否进行医保减员">
              <a-switch v-if="hasYibao" style="margin-left: 10px" :default-checked="isYibaoJianYuan" @change="onJyChange2" />
              <div v-if="!hasYibao" class="rowdialog">
                <img style="width: 14px; height: 14px; margin-left: 10px" src="@/assets/img/tanhao.png" />
                <div style="color: #a6a8b4; font-size: 14px; margin-left: 5px">员工未缴纳医保</div>
              </div>
            </a-form-item>

            <a-form-item v-if="hasYibao && isYibaoJianYuan" class="baseInfo-item" label="医保停保起始年月">
              <a-month-picker
                :default-value="moment(yibaoDate, monthFormat)"
                style="margin-left: 10px"
                @change="onYearMonthChange_YB"
                :allowClear="false"
                :disabled-date="disabledDate2"
              />
            </a-form-item>

            <a-form-item class="baseInfo-item" label="是否进行公积金封存">
              <a-switch v-if="hasGjj" style="margin-left: 10px" :default-checked="isGjjJianYuan" @change="onJY2Change" />
              <div v-if="!hasGjj" class="rowdialog">
                <img style="width: 14px; height: 14px; margin-left: 10px" src="@/assets/img/tanhao.png" />
                <div style="color: #a6a8b4; font-size: 14px; margin-left: 5px">员工未缴纳公积金</div>
              </div>
            </a-form-item>
            <a-form-item v-if="hasGjj && isGjjJianYuan" class="baseInfo-item" label="公积金封存起始年月">
              <a-month-picker
                :default-value="moment(gongjijinDate, monthFormat)"
                style="margin-left: 10px"
                @change="onYearMonthChange_GJJ"
                :allowClear="false"
                :disabled-date="disabledDate2"
              />
              <div style="color: #a6a8b4; font-size: 10px; margin-top: -10px; margin-left: 18px">
                如仅停缴公积金，请前往新建无参保公积金方案
              </div>
            </a-form-item>
            <a-form-item class="baseInfo-item" label="服务费" v-if="hasGjj || hasShebao || hasYibao">
              <a-input-number
                :min="0"
                v-model="serviceCost"
                :precision="2"
                :disabled="(isShebaoJianYuan || isGjjJianYuan || isYibaoJianYuan) === false"
                style="margin-left: 10px; width: 180px"
              />
              <div style="color: #a6a8b4; font-size: 10px; margin-top: -10px; margin-left: 18px">
                服务费不填写默认不更改，填0即服务费改为0
              </div>
            </a-form-item>
          </a-form>
        </div>
      </a-modal>

      <!-- button group  end-->
      <!-- :row-selection="{
            selectedRowKeys: selectedRowKeys,
            onChange: onSelectChange
      }"-->
      <div class="table">
        <a-table
          :scroll="{ x: 1200 }"
          :columns="managementList.title"
          :row-key="(record) => record.id"
          :data-source="managementList.data"
          :pagination="managementList.pagination"
          :loading="managementList.loading"
          size="middle"
          @change="handleTableChange"
        >
          <template slot="status" slot-scope="text, record">
            <div>
              <span v-if="selectId != '0'" :style="'color:' + getColor(text, record, selectId)">•</span>
              {{ getEmployeeStatus(text, record, selectId) }}
            </div>
          </template>

          <template slot="operate" slot-scope="text, record">
            <div v-if="selectId == 0">
              <a-button
                v-if="record.userId == '' || record.userId == null || record.userId == undefined"
                size="small"
                type="link"
                style="padding-left: 0; padding-right: 13px"
                @click="openUser(record)"
                >开通账号</a-button
              >
              <span v-else>已开通账号</span>
              <a-divider type="vertical" />
              <a-button size="small" type="link" @click="detail(record, 7)">详情</a-button>
            </div>

            <div v-if="selectId == 1">
              <a-button
                v-if="getEmployeeStatus(text, record, selectId) === '待入职'"
                style="padding-left: 0"
                :disabled="record.approvalStatus != 4 && record.approvalStatus != 5"
                size="small"
                type="link"
                @click="confirmJoin(record)"
                >确认到岗</a-button
              >
              <a-tooltip placement="topLeft" v-if="getEmployeeStatus(text, record, selectId) === '审批中'">
                <template slot="title">
                  <span>审批中，审批通过后即可操作</span>
                </template>
                <a-button
                  style="padding-left: 0; color: #b8b8b8"
                  :disabled="record.approvalStatus != 4 && record.approvalStatus != 5"
                  size="small"
                  type="link"
                  >确认到岗</a-button
                >
              </a-tooltip>

              <a-divider
                type="vertical"
                v-if="getEmployeeStatus(text, record, selectId) === '审批中' || getEmployeeStatus(text, record, selectId) === '待入职'"
              />
              <a-popconfirm
                placement="topRight"
                ok-text="确认"
                cancel-text="取消"
                @confirm="noConfirmJoin(record)"
                v-if="getEmployeeStatus(text, record, selectId) === '待入职'"
              >
                <template slot="title">
                  <p>确定要未到岗操作？</p>
                </template>
                <a-button size="small" type="link">未到岗</a-button>
              </a-popconfirm>

              <a-tooltip placement="topLeft" v-if="getEmployeeStatus(text, record, selectId) === '审批中'">
                <template slot="title">
                  <span>审批中，审批通过后即可操作</span>
                </template>
                <a-button size="small" type="link" style="padding-left: 0; color: #b8b8b8">未到岗</a-button>
              </a-tooltip>

              <a-button
                size="small"
                type="link"
                v-if="getEmployeeStatus(text, record, selectId) === '审批驳回'"
                @click="resJoinOrreApproval(record, 2)"
                >再次发起</a-button
              >

              <a-button
                size="small"
                type="link"
                v-if="getEmployeeStatus(text, record, selectId) === '未到岗'"
                @click="resJoinOrreApproval(record, 1)"
                >重新入职</a-button
              >
              <a-divider type="vertical" />
              <a-button size="small" type="link" @click="detail(record, 2)">详情</a-button>
              <a-button
                size="small"
                type="link"
                :style="{ visibility: 'hidden' }"
                v-if="getEmployeeStatus(text, record, selectId) === '未到岗' || getEmployeeStatus(text, record, selectId) === '审批驳回'"
                >重新入职</a-button
              >
            </div>

            <div v-if="selectId == 3">
              <a-button
                style="padding-left: 0"
                :disabled="record.approvalStatus != 4 && record.approvalStatus != 5"
                size="small"
                type="link"
                @click="makeTransfer(record)"
                >调岗</a-button
              >
              <a-divider type="vertical" />
              <a-button
                :disabled="record.approvalStatus != 4 && record.approvalStatus != 5"
                size="small"
                type="link"
                @click="makeLeave(record)"
                >离职</a-button
              >
              <a-divider type="vertical" />
              <a-button size="small" type="link" @click="detail(record, 5)">详情</a-button>
            </div>
            <div v-if="selectId == 2">
              <a-button style="padding-left: 0" :disabled="record.approvalStatus != 5" type="link" @click="confirmRegular(record)"
                >转正</a-button
              >
              <a-divider type="vertical" />
              <a-button
                size="small"
                :disabled="record.approvalStatus != 5 && record.approvalStatus != 4"
                type="link"
                @click="makeLeave(record)"
                >离职</a-button
              >
              <a-divider type="vertical" />
              <a-button size="small" type="link" @click="detail(record, 4)">详情</a-button>
            </div>
            <div v-if="selectId == 4">
              <a-button
                style="padding-left: 0"
                :disabled="(record.approvalStatus != 5 && record.approvalStatus != 4) || record.status == 4"
                size="small"
                type="link"
                @click="confirmLeave(record)"
                >确认离职</a-button
              >
              <a-divider type="vertical" />
              <a-button
                :disabled="(record.approvalStatus != 5 && record.approvalStatus != 4) || record.status == 4"
                size="small"
                type="link"
                @click="revokeLeave(record)"
                >撤销离职</a-button
              >
            </div>
            <div v-if="selectId == 5">
              <a-button
                style="padding-left: 0"
                :disabled="record.approvalStatus != 5 && record.approvalStatus != 4"
                size="small"
                type="link"
                @click="confimTransferPosition(record)"
                >确认调岗</a-button
              >
              <a-divider type="vertical" />
              <a-button
                :disabled="record.approvalStatus != 5 && record.approvalStatus != 4"
                size="small"
                type="link"
                @click="revokeTransferPosition(record)"
                >撤销调岗</a-button
              >
            </div>
          </template>
        </a-table>
      </div>
    </div>

    <!-- 办理入职 -->
    <a-drawer title="办理入职" :width="540" :visible="visibleDrawer" :wrap-style="{ overflow: 'auto' }" @close="onCloseDrawer('')">
      <a-form :form="entryForm" @submit="handleSubmit">
        <div class="drawer-title mb24">基本信息</div>
        <a-row :gutter="16">
          <a-form-item label="姓名:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-input
              v-decorator="[
                'name',
                {
                  rules: [{ required: true, message: '请输入姓名' }]
                }
              ]"
              placeholder="请输入姓名"
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="手机号码:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-input
              v-decorator="[
                'phone',
                {
                  rules: [{ required: true, message: '请输入手机号' }, { validator: validPhone }]
                }
              ]"
              :max-length="11"
              placeholder="请输入手机号码"
            />
          </a-form-item>
        </a-row>

        <a-row :gutter="16">
          <a-form-item label="部门:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-col :span="23">
              <a-tree-select
                v-decorator="[
                  'depIdList',
                  {
                    rules: [{ required: true, message: '请选择部门' }]
                  }
                ]"
                :tree-data="depInfoOptions"
                allow-clear
              />
            </a-col>
            <a-col :span="1">
              <a-button type="link" @click="toPage('/organization/organization')">去添加</a-button>
            </a-col>
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="岗位:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-col :span="23">
              <a-tree-select
                v-decorator="[
                  'positionIdList',
                  {
                    rules: [{ required: true, message: '请选择岗位' }]
                  }
                ]"
                :tree-data="positionOptions"
                allow-clear
              />
            </a-col>
            <a-col :span="1">
              <a-button type="link" @click="toPage('/organization/org')">去添加</a-button>
            </a-col>
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="工作性质:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-select v-decorator="['postType']" placeholder="请选择工作性质">
              <a-select-option v-for="item in postTypeOptions2" :key="item.value" :value="item.value">{{ item.label }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="预计入职日期:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-date-picker
              v-decorator="[
                'preJoinDate',
                {
                  rules: [{ required: true, message: '请选择预计入职日期' }]
                }
              ]"
              type="date"
            />
          </a-form-item>
        </a-row>
        <div class="drawer-footer-box">
          <a-button :style="{ marginRight: '12px' }" type="primary" html-type="submit">提交</a-button>
          <a-button @click="onCloseDrawer('')">取消</a-button>
        </div>
      </a-form>
    </a-drawer>

    <!-- 转正 -->
    <a-drawer
      title="转正"
      :width="540"
      :visible="visibleRegularDrawer"
      :wrap-style="{ overflow: 'auto' }"
      @close="onCloseDrawer('Regular')"
    >
      <a-form :form="regularForm" @submit="handleRegularSubmit">
        <div class="drawer-title mb24">基本信息</div>
        <a-row :gutter="16">
          <a-form-item label="姓名:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-input v-decorator="['name', { initialValue: regularFormData.name }]" placeholder="请输入姓名" disabled />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="手机号码:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-input v-decorator="['phone', { initialValue: regularFormData.phone }]" placeholder="请输入手机号码" disabled />
          </a-form-item>
        </a-row>

        <a-row :gutter="16">
          <a-form-item v-if="regularFormData.employType === 0" label="形式:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-select v-decorator="['informalType', { initialValue: regularFormData.informalType }]" disabled placeholder="请选择">
              <a-select-option v-for="item in informalTypeOptions" :key="item.value" :value="item.value">{{ item.label }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-row>

        <a-row :gutter="16">
          <a-form-item label="部门:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-tree-select
              v-decorator="['depIdList', { initialValue: regularFormData.depName }]"
              disabled
              :tree-data="depInfoOptions"
              multiple
              allow-clear
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="岗位:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-tree-select
              v-decorator="['positionIdList', { initialValue: regularFormData.positionName }]"
              disabled
              :tree-data="positionOptions"
              multiple
              allow-clear
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="入职日期:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-date-picker v-decorator="['joinDate', { initialValue: getMoment(regularFormData.joinDate) }]" disabled type="date" />
          </a-form-item>
        </a-row>
        <div class="drawer-title mb24">转正日期</div>
        <a-row :gutter="16">
          <a-form-item label="转正日期:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-date-picker
              :disabled-date="disabledDateRegularDate"
              v-decorator="[
                'regularDate',
                {
                  rules: [{ required: true, message: '请选择转正日期' }]
                }
              ]"
              type="date"
              format="YYYY-MM-DD"
            />
          </a-form-item>
        </a-row>
        <div class="drawer-footer-box">
          <a-button :style="{ marginRight: '12px' }" @click="onCloseDrawer('Regular')">取消</a-button>
          <a-button type="primary" html-type="submit">确定</a-button>
        </div>
      </a-form>
    </a-drawer>
    <!-- 离职 -->
    <a-drawer
      title="办理离职"
      :width="540"
      :visible="visibleLeaveDrawer"
      :wrap-style="{ overflow: 'auto' }"
      @close="onCloseDrawer('Leave')"
    >
      <a-form :form="leaveForm" @submit="handleLeaveSubmit">
        <a-alert class="mb20" message="可选择员工办理离职，提交后所选员工将进入待离职状态" banner closable />
        <a-row :gutter="16">
          <a-form-item label="姓名:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-textarea
              :auto-size="{ minRows: 1, maxRows: 3 }"
              ref="nameModal"
              v-decorator="[
                'name',
                {
                  rules: [{ required: true, message: '必选' }]
                }
              ]"
              placeholder="请选择员工"
              :disabled="nameDisable"
              autocomplete="off"
              @click="showMeberDialog"
              @contextmenu.prevent="showMeberDialog"
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="预计离职日期:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-date-picker
              :disabled-date="disabledDateRegularDate"
              v-decorator="[
                'preQuitDate',
                {
                  rules: [{ required: true, message: '请选择预计离职日期' }]
                }
              ]"
              type="date"
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="离职原因:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <div class="selectBoxs" @click="showLeaveModal">
              <a-select
                ref="selectModal"
                v-decorator="['quitReason', { rules: [{ required: true, message: '请选择离职原因' }] }]"
                onbeforeactivate="false"
                mode="multiple"
                :notFoundContent="null"
                @change="LeaveChange"
              />
            </div>
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="离职备注:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-textarea v-decorator="['quitRemarks']" placeholder="请输入备注" :rows="4" />
          </a-form-item>
        </a-row>

        <div class="drawer-footer-box">
          <a-button :style="{ marginRight: '12px' }" @click="onCloseDrawer('Leave')">取消</a-button>
          <a-button type="primary" html-type="submit">确定</a-button>
        </div>
      </a-form>
    </a-drawer>
    <!-- 办理调岗 -->
    <a-drawer title="办理调岗" :width="540" :visible="visibleMoveDrawer" :wrap-style="{ overflow: 'auto' }" @close="onCloseDrawer('Move')">
      <a-form :form="moveForm" @submit="handleMoveSubmit">
        <a-alert class="mb20" message="可选择员工办理调岗，提交后所选员工将进入待调岗状态" banner closable />
        <a-row :gutter="16">
          <a-form-item label="姓名:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-textarea
              :auto-size="{ minRows: 1, maxRows: 3 }"
              ref="nameModal"
              v-decorator="[
                'name',
                {
                  rules: [{ required: true, message: '必选' }]
                }
              ]"
              placeholder="请选择员工"
              :disabled="nameDisabled"
              autocomplete="off"
              @contextmenu.prevent="showMeberDialog"
              @click="showMeberDialog"
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="岗位变更为" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-tree-select
              v-decorator="[
                'currentPositionIdList',
                {
                  rules: [{ required: true, message: '必填' }]
                }
              ]"
              :tree-data="positionOptions"
              allow-clear
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="部门变更为" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-tree-select
              v-decorator="[
                'currentDepIdList',
                {
                  rules: [{ required: true, message: '必填' }]
                }
              ]"
              :tree-data="depInfoOptions"
              allow-clear
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="调岗日期:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-date-picker
              v-decorator="[
                'adjustmentDate',
                {
                  rules: [{ required: true, message: '请选择调岗日期' }]
                }
              ]"
              type="date"
            />
          </a-form-item>
        </a-row>
        <a-row :gutter="16">
          <a-form-item label="调岗原因:" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
            <a-input v-decorator="['adjustmentReason']" type="textarea" />
          </a-form-item>
        </a-row>

        <div class="drawer-footer-box">
          <a-button :style="{ marginRight: '12px' }" @click="onCloseDrawer('Move')">取消</a-button>
          <a-button type="primary" html-type="submit">确定</a-button>
        </div>
      </a-form>
    </a-drawer>

    <!-- 员工直接添加 -->

    <!-- 确认到岗modal -->
    <a-modal
      :title="drawerTitle"
      :visible="visibleConfimSubmit"
      :confirm-loading="false"
      :z-index="1050"
      @cancel="handleCancelSubmit('visibleConfimSubmit')"
    >
      <template slot="footer">
        <a-button @click="handleCancelSubmit('visibleConfimSubmit')">关闭</a-button>
      </template>
      <div class="modal-box">
        <img class="w200" src="@/assets/img/3.png" alt />
        <h3 class="modal-title">
          <span>{{ drawerTitle }}成功</span>
        </h3>
        <p class="modal-content">
          <span>
            {{
              drawerTitle === "确认到岗"
                ? getShiyongqi()
                  ? "可在'转正管理'中查看员工入职相关信息"
                  : "可在'在职管理'中查看员工入职相关信息"
                : "可在'入职管理'中，重新入职"
            }}
          </span>
        </p>
      </div>
    </a-modal>

    <!-- 审批 -->
    <a-modal
      :title="titleSubmit"
      :visible="visibleSubmit"
      :confirm-loading="false"
      cancel-text="关闭"
      :ok-text="oktext"
      :z-index="1050"
      @ok="onJoinEmp"
      @cancel="handleCancelSubmit('visibleSubmit')"
    >
      <div v-if="FlowsData.length === 0" class="modal-box">
        <img class="w200" src="@/assets/img/1.png" alt />
        <h3 class="modal-title">
          <span v-if="flag === 1">提交成功</span>
          <span v-if="flag === 2">{{ iszheng ? "转正成功" : "转正日期修改成功" }}</span>
          <span v-if="flag === 3">已提交至待离职列表</span>
          <span v-if="flag === 4">已提交至待调岗列表</span>
        </h3>
        <p v-if="flag === 1" class="modal-content">
          <!-- 已自动发送入职邀请至对方手机 -->
          需要手动发送入职邀请至对方手机
        </p>

        <p class="modal-content">
          <span v-if="flag === 1">可在转正管理里查看员工入职相关信息</span>
          <span v-if="flag === 2">可在{{ iszheng ? "在职管理" : "转正管理" }}查看员工相关信息</span>
          <span v-if="flag === 3">可在待离职列表内确认离职或撤销离职</span>
          <span v-if="flag === 4">可在待调岗列表内确认调岗或撤销调岗</span>
        </p>
      </div>
      <div v-else class="modal-box">
        <img class="w200" src="@/assets/img/2.png" alt />
        <h3 class="modal-title">待审批</h3>
        <p class="modal-content">已提交至审批流程</p>
        <!-- <p class="modal-content">
          待审批通过后，
          <span v-if="flag === 1">可在入职管理里查看员工入职信息</span>
          <span v-if="flag === 2">即可转正</span>
          <span v-if="flag === 3">即可离职</span>
          <span v-if="flag === 4">即可调岗</span>
        </p>-->
        <p v-if="flag === 1">审批通过后需要手动发送入职邀请至对方手机</p>
      </div>
    </a-modal>
    <a-modal
      title="选择审批模板"
      :visible="approvalModal"
      :confirm-loading="false"
      cancel-text="关闭"
      ok-text="下一步"
      :z-index="1020"
      @ok="handleApprovalSubmit"
      @cancel="approvalModal = false"
    >
      <div class="modal-box overflow-y400">
        <a-radio-group v-model="selectValue" style="width: 100%" @change="onselectValueChange">
          <a-row v-for="item in FlowsData" :key="item.id" type="flex" align="middle" class="mb20">
            <a-col class="icon mg_r10">
              <img style="width: 48px" :src="item.icon" alt="加载失败" />
            </a-col>
            <a-col>
              <a-row class="title1 ta-left">{{ item.typeName }}</a-row>
              <a-row class="subTitle ta-left">{{ item.typeDesc }}</a-row>
            </a-col>
            <a-col class="ta-right" style="flex: 1">
              <a-radio :value="item.id" />
            </a-col>
          </a-row>
        </a-radio-group>
      </div>
    </a-modal>

    <a-modal
      title="选择离职原因"
      :visible="visibleLeaveModal"
      :confirm-loading="false"
      cancel-text="取消"
      ok-text="确定"
      @ok="confirmLeaveModal"
      @cancel="handleCancelLeaveModal"
    >
      <a-checkbox-group v-model="checkedListGroup" @change="onChangeLeaveModal">
        <a-row class="lh40">
          <a-col class="drawer-title mb20" :span="24">主动原因</a-col>
          <a-col :span="12">
            <a-checkbox value="家庭原因">家庭原因</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="个人原因">个人原因</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="发展原因">发展原因</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="合同到期不续签">合同到期不续签</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="其他">其他</a-checkbox>
          </a-col>
          <a-col class="drawer-title mb20 mt20" :span="24">被动原因</a-col>
          <a-col :span="12">
            <a-checkbox value="协议解除">协议解除</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="无法胜任工作">无法胜任工作</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="经济性裁员">经济性裁员</a-checkbox>
          </a-col>
          <a-col :span="12">
            <a-checkbox value="严重违法违纪">严重违法违纪</a-checkbox>
          </a-col>
        </a-row>
      </a-checkbox-group>
    </a-modal>

    <a-modal
      destroy-on-close
      width="800px"
      top="100px"
      class="empInfoDialog"
      title="选择员工"
      :visible="visibleMerber"
      :z-index="1003"
      @cancel="visibleMerber = false"
    >
      <a-input
        v-model="nameOrPhoneOrEmail"
        style="width: 30%; margin-bottom: 10px"
        placeholder="请输入姓名、身份证号或手机号"
        @keyup.enter.native="selectEmp"
      />
      <a-table
        ref="empInfoTable"
        :row-selection="{
          selectedRowKeys: selectedTempRowKeys,
          onChange: selectionChange,
          type: 'radio'
        }"
        :data-source="empInfoList"
        :pagination="pagination"
        :columns="columns"
        :row-key="(record) => record.id"
        size="small"
        @change="handleEmpInfoTableChange"
      />

      <div slot="footer" class="dialog-footer">
        <a-button @click="visibleMerber = false">取 消</a-button>
        <a-button type="primary" class="adjust-button" :disabled="adjustButtonDisabled" @click="adjustEmp">添加</a-button>
      </div>
    </a-modal>
    <positonTree v-if="positonTreeShow" :list="[]" @getPositionList="getPositionList" @cancelPositionList="cancelPositionList" />
    <a-drawer
      :title="drawerTitle"
      :width="580"
      :destroyOnClose="true"
      :visible="visibleEmpyleeDrawer2"
      :wrap-style="{ overflow: 'auto' }"
      @close="onCloseDrawer2('visibleEmpyleeDrawer2')"
    >
      <DynamicAddEmployees
        v-if="drawerTitle === '添加待入职'"
        @saveValueChange="saveValueChange"
        :outEmpDetail="joinFormData"
        @cancelForm="cancelForm"
        :title="drawerTitle"
        :moduleCode="'waitJob'"
      ></DynamicAddEmployees>
      <DynamicAddEmployees
        v-else
        :outEmpDetail="joinFormData"
        @saveValueChange="saveValueChange"
        @cancelForm="cancelForm"
        :title="drawerTitle"
        :confirmedPost="true"
        :moduleCode="'onJob'"
      ></DynamicAddEmployees>
      <a-modal :footer="null" :bodyStyle="{ height: '180px' }" v-model="haveResigned" title="数据同步" width="600px">
        <div style="font-size: 16px; font-weight: 500; padding-left: 24px">{{ reasonResigned ? reasonResigned : "--" }}</div>
        <div>
          <div style="margin-top: 12px">
            <span style="font-size: 14px; font-weight: 400; padding-left: 24px; color: #ff0000">*</span>
            若希望信息同步，请前往花名册为其更换用工单位
          </div>
          <div>
            <span style="font-size: 14px; font-weight: 400; padding-left: 24px; color: #ff0000">*</span> 若不需要信息同步，请点击继续添加
          </div>
          <div style="padding-left: 24px" v-if="companyIdResigned && !companyIdResigned.haveAuthority">
            （您没有【{{ companyIdResigned.companyName }}】的访问权限，无法为其更换用工单位）
          </div>
        </div>
        <div class="drawer-footer-box2">
          <a-button :style="{ marginRight: '12px' }" :disabled="companyIdResigned && !companyIdResigned.canAdd" @click="handleResigneCancel"
            >继续添加</a-button
          >
          <a-button type="primary" html-type="submit" :disabled="companyIdResigned && !companyIdResigned.haveAuthority" @click="handleOk"
            >前往花名册</a-button
          >
        </div>
      </a-modal>
    </a-drawer>
    <a-modal title="添加待入职" :visible="isCloseMethod2" width="520px" :destroy-on-close="true" @cancel="handleCancel">
      <template slot="footer">
        <a-button @click="handleCancel">关闭</a-button>
        <a-button key="submit" type="primary" ghost @click="handleCancel">确定</a-button>
      </template>

      <div style="display: flex; flex-flow: column; align-items: center">
        <img v-if="!isApproval" style="width: 200px; height: 200px" src="@/assets/img/1.png" />
        <img v-else style="width: 200px; height: 200px" src="@/assets/img/2.png" />
        <span style="font-size: 20px; font-weight: 800">{{ !isApproval ? "提交成功" : "审批中" }}</span>
        <span style="color: #00000077; margin-top: 12px; margin-bottom: 12px">
          {{ !isApproval ? "可在入职管理中选择确认到岗或者未到岗" : "已提交至审批流程" }}
        </span>
      </div>
    </a-modal>
    <a-modal title="选择审批模板" :visible="selectModel" width="520px" :destroy-on-close="true" @cancel="handleCancel">
      <template slot="footer">
        <a-button @click="handleCancel">取消</a-button>
        <a-button key="submit" type="primary" ghost @click="finishEdit3">下一步</a-button>
      </template>

      <div style="display: flex; flex-flow: column; align-items: center">
        <div
          v-for="(item, i) in templatesListGroup"
          :key="i"
          @click="temClick(item)"
          style="
            padding-top: 10px;
            padding-bottom: 10px;
            padding-right: 15px;
            width: 100%;
            display: flex;
            flex-flow: row;
            align-items: center;
            justify-content: space-between;
          "
          :class="{ backgroundC: item.select }"
        >
          <div style="display: flex; flex-flow: row">
            <img style="width: 52px; height: 52px; margin-right: 15px" src="@/assets/img/模板icon.png" />
            <div>
              <span style="display: flex; flex-flow: column; font-size: 16px; font-weight: 600">{{ item.typeName }}</span>
              <span style="color: #00000077">{{ item.typeDesc }}</span>
            </div>
          </div>
          <xq-icon type="icon-wancheng2" v-if="item.select" class="primary_color fs20"></xq-icon>
        </div>
      </div>
    </a-modal>
    <a-modal
      title="批量转正"
      :visible="visiblePositive"
      :confirm-loading="confirmLoadingPositive"
      @ok="handleOkPositive"
      @cancel="handleCancelPositive"
    >
      <a-form :form="formPositive" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
        <a-form-item label="转正日期">
          <a-date-picker
            :disabled-date="disabledDateRegularDate"
            v-decorator="['regularDate', { rules: [{ required: true, message: '请选择转正日期!' }] }]"
          />
        </a-form-item>
      </a-form>
    </a-modal>
    <a-drawer
      :title="'确认到岗'"
      :width="580"
      :destroyOnClose="true"
      :visible="visibleJoinDate"
      :wrap-style="{ overflow: 'auto' }"
      @close="onCloseDrawer2('visibleJoinDate')"
    >
      <DynamicAddEmployees
        :outEmpDetail="confirmedPostArr"
        @saveValueChange="handleOkJoinDate"
        @cancelForm="cancelForm"
        :isBatchJoin="isBatchJoin"
        :title="'确认到岗'"
        :moduleCode="'onJob'"
      ></DynamicAddEmployees>
    </a-drawer>
    <!-- 批量确认离职和批量离职  -->
    <BatchLeaveFilter
      ref="BatchLeaveFilterSelect"
      @bulkDeparturesOk="bulkDeparturesOk"
      @saveOk="saveLeaveOk"
      @querenlizhi="onQuerenlizhi"
    />
    <!-- 其他高级筛选 -->
    <employeesMoveAdvancedScreening ref="employeesMove" @getNextStep="getNextStep"></employeesMoveAdvancedScreening>
    <a-modal v-model="pilianglizhiResultModal" title="批量离职结果" width="840px" @ok="pilianglizhiModalOk" @cancel="pilianglizhiModalOk">
      <div style="font-size: 16px; margin-bottom: 16px; font-weight: 500">批量离职成功</div>
      <a-table :columns="pilianglizhiColumns" :scroll="{ x: 700 }" rowKey="empId" :dataSource="pilianglizhiResults" />
    </a-modal>
  </div>
</template>
<script>
import {
  getEmpInfoCount,
  leavePosition,
  transferRegular,
  confirmToJoinBatch,
  confirmToNoJoinBatch,
  saveEmpInfoPre,
  selectEmpInfoOnJobRelation,
  selectEmpInfoPendingRelation,
  selectEmpInfoToFormalRelation,
  empRegisterAccount,
  selectEmpInfoTransferRelation,
  onJobAgain,
  confimLeave,
  findEmpHaveSocInfo,
  selectEmpInfoListForLeave,
  revokeLeaveApi,
  confimTransferPositionApi,
  revokeTransferPositionApi,
  onJobFlows,
  pageWaitLeave,
  // 获取某公司离职可用的的所有审批流程
  leavingFlows,
  // 获取某公司调岗可用的的所有审批流程
  transferDutyFlows,
  // 获取某公司转正可用的的所有审批流程
  turnStraightFlows,
  saveEmpInfoAndRule,
  selectResigned,
  batchRevokeTransferPositionByEmpId,
  batchConfirmTransferPosition
} from "@/api/staff/staff";
import { getDepartmentInTree } from "@/api/department/department";
import { getPositionInTree } from "@/api/department/position";
import { transferJob } from "@/api/staff/empChanges";
import { formatDate, formatDateDefault, afterTime } from "@/utils/index";
import { validPhone } from "@/utils/validate";
import { getModelList_isUse } from "@/api/billing/billing";
import positonTree from "@/components/SelectTree/position";
import axios from "axios";
import qs from "qs";
import DynamicAddEmployees from "../management/info/component/dynamicAddEmployees";
import { getEmpField, leaveBatchReq } from "../management/info/api";
import moment from "moment";
import BatchLeaveFilter from "./component/batchLeaveFilter";
import { tabList, managementList, columnDialogDetailguding, pagination, pagination1, pilianglizhiColumns } from "./indexFuncs";
import employeesMoveAdvancedScreening from "./component/employeesMoveAdvancedScreening";
export default {
  components: { BatchLeaveFilter, DynamicAddEmployees, positonTree, employeesMoveAdvancedScreening },
  inject: ["reload"],
  data() {
    return {
      pilianglizhiColumns,
      pilianglizhiResults: [],
      pilianglizhiResultModal: false,
      batchPreQuitDate: null,
      leaveEmyList: [],
      isBatchLeaveConfirm: false,
      isBatchJoin: false,
      disableJoinDate: null,
      confirmedPostArr: {},
      visibleJoinDate: false,
      confirmLoadingJoinDate: false,
      formPositive: this.$form.createForm(this, { name: "coordinated" }),
      formJoinDate: this.$form.createForm(this, { name: "coordinated1" }),
      visiblePositive: false,
      confirmLoadingPositive: false,
      batchArrData: [],
      openBulkDepartures: false,
      selectedRowKeysModelIds: [],
      outEmpDetail: {},
      saveValueFrom: {},
      tempTemplate: undefined,
      templatesListGroup: [],
      isApproval: true,
      isCloseMethod2: false,
      selectModel: false,
      isOut: false,
      status2: [
        { value: 1, label: "试用", name: "countWaitInformalAll", count: 0 },
        { value: 2, label: "正式", name: "countHasInformalAll", count: 0 }
      ],
      empState: true,
      serviceCost: undefined,
      empyleeForm: this.$form.createForm(this),
      liststatus: [
        { value: "待入职", id: "1" },
        { value: "审批中", id: "2" },
        { value: "审批驳回", id: "3" },
        { value: "未到岗", id: "4" }
      ],
      visibleEmpyleeDrawer2: false,
      spinning: false,
      zzbm: undefined,
      lzbm: undefined,
      nameDisable: false,
      nameDisabled: false,
      columnDialogDetailguding,
      selectId: "1",
      pagination: pagination1,
      tabList,
      // 筛选条件
      searchForm: {},
      columns: [
        { title: "姓名", dataIndex: "name" },
        { title: "身份证号", dataIndex: "idCard", width: 200 },
        { title: "手机号", dataIndex: "phone" },
        {
          title: "工作性质",
          dataIndex: "postType",
          customRender: (text, record, index) => {
            return this.$store.state.enums.postTypeArr[text - 1];
          }
        },
        {
          title: "入职日期",
          dataIndex: "joinDate",
          customRender: (text, record, index) => {
            return formatDate(text);
          }
        }
        // { title: "工作邮箱", dataIndex: "email" }
      ],
      pagination2: {
        pageSize: 10,
        total: 0,
        size: "default",
        current: 1
        // showQuickJumper: true
      },
      validPhone,
      haveResigned: false,
      reasonResigned: null,
      companyIdResigned: null,
      visibleModal: false,
      leaveTag: false,
      moveTag: false,
      selectValue: "",
      isCloseMethod: false,
      leaveEmy: undefined,

      empInfoList: [],
      titleSubmit: "办理入职",
      drawerTitle: "",
      oktext: "继续办理",
      visibleConfimSubmit: false,
      visibleJoinDrawer: false,
      visibleLeaveDrawer: false,
      visibleRegularDrawer: false,
      visibleEmpyleeDrawer: false,
      visibleLeaveModal: false,
      visibleMoveDrawer: false,
      entryForm: this.$form.createForm(this),

      regularForm: this.$form.createForm(this),
      leaveForm: this.$form.createForm(this),
      // empyleeForm: this.$form.createForm(this),
      moveForm: this.$form.createForm(this),
      employTypeOptions: [{ value: "1", label: "正式" }],
      employType: "",
      informalTypeOptions: [
        { value: "1", label: "实习" },
        { value: "2", label: "劳务" },
        { value: "3", label: "雇佣" },
        { value: "4", label: "返聘" },
        { value: "5", label: "外包" }
      ],
      action: "",
      depInfoOptions: [],
      depInfoOptions2: [], // 在所有部门的基础上手动添加了没有任何部门的选项
      positionOptions: [],
      adjustButtonDisabled: false,
      shebaoDate: moment().format("YYYY-MM"),
      gongjijinDate: moment().format("YYYY-MM"),
      yibaoDate: moment().format("YYYY-MM"),
      visibleMerber: false,
      visibleSubmit: false,
      iszheng: false,
      approvalModal: false,
      visibleDrawer: false,
      checkedListGroup: [],
      dataDetail2: [],
      joinFormData: {},
      regularFormData: {},
      companyId: "",
      selectBox: false,
      total: 0,
      sexvalue: "",
      depIdvalue: "",
      employTypevalue: "",
      formalTypevalue: "",
      selectedRowKeys: [],
      selectedTempRowKeys: [],
      monthFormat: "YYYY-MM",
      leaveFormat: "YYYY-MM-DD",
      isShebaoJianYuan: false,
      isYibaoJianYuan: false,
      isGjjJianYuan: false,
      hasShebao: false,
      hasGjj: false,
      hasYibao: false,
      renliStatus: 0, // 0拖拽，1成功，2失败
      // 表格
      managementList,
      leaveList: [],
      // 姓名或手机号
      nameOrPhoneOrEmail: "",
      // 性别
      sexOptions: [
        { value: "1", label: "男" },
        { value: "2", label: "女" }
      ],
      sex: "",
      depId: "",
      // 转正状况
      formalTypeOptions: [
        { value: 1, label: "试用期" },
        { value: 2, label: "转正" }
      ],
      // 员工排序
      staffSort: [
        { id: 0, name: "发起离职合同", key: "namePinyin" },
        { id: 1, name: "导入Excel办理", key: "gmtCreate" },
        { id: 2, name: "已离职记录", key: "gmtModified" }
      ],
      formalType: "",
      FlowsData: [],
      redisValues: {},
      gmtOrder: "gmtCreate",
      joinFormStatus: undefined,
      preJoinDateEnd: undefined,
      preJoinDateStart: undefined,
      positonTreeShow: false,
      checkedPostionListGroup: [],
      socFile: undefined,
      isHeTong: false,
      piliang_shebaojianyuan: false,
      newType: null,
      // channelId: "", // 渠道id
      // 转正日期
      proRegularDateShow: false,
      // 试用日期
      testDate: false,
      flag: 0, // 文字显示状态
      currentItem: undefined,
      EmpState: null
    };
  },
  computed: {
    postTypeOptions2() {
      return this.$store.state.enums.postTypeLst;
    }
  },
  created() {
    if (this.$route.query.selectId) {
      this.selectId = this.$route.query.selectId;
      this.leaveTag = this.$route.query.leaveTag;
      this.moveTag = this.$route.query.moveTag;
      this.searchForm.nameOrPhone = this.$route.query.nameOrPhone;
    }
    if (this.$route.query.outEmpDetail) {
      this.drawerTitle = "添加待入职";
      if (this.$route.query.EmpState) {
        this.EmpState = this.$route.query.EmpState;
      }
      this.outEmpDetail = JSON.parse(this.$route.query.outEmpDetail);
      this.outEmpDetail.idCard = this.outEmpDetail.idcard + "";
      if (this.outEmpDetail.joinDate) {
        this.outEmpDetail.joinDate = this.$moment(this.outEmpDetail.joinDate).format("YYYY-MM-DD");
      }
      const data1 = this.outEmpDetail;
      Object.keys(data1).map((z) => {
        if (typeof data1[z] === "number" && data1[z].toString().length === 1) {
          data1[z] = data1[z] + "";
        }
      });
      this.joinFormData = data1;
    }
    if (this.EmpState === "out") {
      this.visibleEmpyleeDrawer2 = true;
      this.EmpState = false;
    }
    this.companyId = this.$store.state.hr.companyId;

    if (this.$route.query.selectId || this.$route.query.outEmpDetail) {
      // 外部带参数跳转进来的
      pagination.current = 1;
    } else {
      // 读取缓存
      this.getCaCh();
    }
    this.getTabNumber();
    this.getEmpInfos();
    getDepartmentInTree({ companyId: this.companyId }).then((res) => {
      this.depInfoOptions = this.tree(res.data[0].depChildList, "depChildList", false);
      this.depInfoOptions2 = this.tree(res.data[0].depChildList, "depChildList", false);
    });
    getPositionInTree({ companyId: this.companyId }).then((res) => {
      this.positionOptions = this.tree1(res.data[0].positionChildList, "positionChildList", true);
    });
  },
  mounted() {
    const st = this.$route.query.operateFromShortcut;
    if (st) {
      switch (st) {
        case "rzdl":
          break;
      }
    }
  },
  methods: {
    formatLeaveEmyListNames(list) {
      if (list.length > 2) {
        return `${list[0].name}等 ${list.length} 人`;
      } else {
        return list.map((item) => item.name).join("、");
      }
    },
    getCaCh() {
      if (JSON.stringify(this.$getCondition("ygyd_condition")) !== "{}") {
        var dparams = JSON.parse(this.$getCondition("ygyd_condition"));
        if (dparams.companyId && dparams.companyId === this.$store.state.hr.companyId) {
          if (dparams.selectId) {
            this.selectId = dparams.selectId;
          }
          if (dparams.nameOrPhone) {
            this.searchForm.nameOrPhone = dparams.nameOrPhone;
          }
          if (dparams.approvalAndStatus) {
            this.searchForm.approvalAndStatus = dparams.approvalAndStatus;
          }
          if (dparams.joinFormStatus) {
            this.searchForm.joinFormStatus = dparams.joinFormStatus;
          }
          // 预计入职开始时间
          if (dparams.preJoinDateStart && dparams.preJoinDateEnd) {
            this.searchForm.preJoinDateMoment = [dparams.preJoinDateStart, dparams.preJoinDateEnd];
          }
          // 入职开始时间
          if (dparams.joinDateStart && dparams.joinDateEnd) {
            this.searchForm.joinDateMoment = [dparams.joinDateStart, dparams.joinDateEnd];
          }
          // 预计转正时间
          if (dparams.turnStraightDateStart && dparams.turnStraightDateEnd) {
            this.searchForm.turnStraightDateMoment = [dparams.turnStraightDateStart, dparams.turnStraightDateEnd];
          }
          // 预计离职时间
          if (dparams.leaveDateStart && dparams.leaveDateEnd) {
            this.searchForm.leaveDateMoment = [dparams.leaveDateStart, dparams.leaveDateEnd];
          }
          //  调岗开始时间 结束时间
          if (dparams.transferDateStart && dparams.transferDateEnd) {
            this.searchForm.transferDateMoment = [dparams.transferDateStart, dparams.transferDateEnd];
          }

          // 读取缓存页码
          if (dparams.pageNo) {
            this.managementList.pagination.current = dparams.pageNo;
          }

          if (dparams.pageSize) {
            this.managementList.pagination.pageSize = dparams.pageSize;
          }
        }
      }
    },
    saveLeaveOk() {
      this.getTabNumber();
      this.tapChange(this.selectId);
    },
    // 批量离职
    batchLeave(e) {
      this.$nextTick(() => {
        this.$refs.BatchLeaveFilterSelect.showModal(e);
      });
    },
    // 继续添加
    handleResigneCancel() {
      this.haveResigned = false;
      this.handleEmpyleeSubmit2Pre();
    },
    // 前往花名册
    handleOk() {
      const data = {
        queryType: 1,
        pageNo: this.pagination.current,
        pageSize: this.pagination.pageSize,
        companyId: this.companyIdResigned.companyId,
        "orders[0].property": this.gmtOrder,
        "orders[0].desc": this.gmtOrder !== "namePinyin"
      };
      const data1 = JSON.parse(JSON.stringify(data));
      data1.joinDateMoment = null;
      this.$store.dispatch("onCompanyClick", {
        id: this.companyIdResigned.companyId,
        name: this.companyIdResigned.companyName
      });

      this.$router.push({
        path: "/staff/detail",
        query: {
          companyId: this.companyIdResigned.companyId,
          searchFormData: data1,
          id: this.companyIdResigned.id,
          userId: this.companyIdResigned.userId
        }
      });
      setTimeout(() => {
        this.$router.go(0);
      }, 1000);
    },
    cancelForm() {
      this.visibleEmpyleeDrawer2 = false;
      this.visibleJoinDate = false;
      this.isBatchJoin = false;
    },
    saveValueChange(data) {
      console.log(data);
      this.saveValueFrom = data;
      if (this.drawerTitle === "添加待入职") {
        selectResigned({
          idCard: this.saveValueFrom.idCard ? this.saveValueFrom.idCard : null,
          phone: this.saveValueFrom.phone ? this.saveValueFrom.phone : null,
          companyId: this.$store.state.hr.companyId
        }).then((res) => {
          if (res.data && res.data.haveResigned) {
            this.haveResigned = true;
            this.reasonResigned = res.data.reason;
            this.companyIdResigned = res.data;
          } else {
            this.handleEmpyleeSubmit2Pre();
          }
        });
      } else {
        this.handleEmpyleeSubmit2Pre();
      }
    },
    temClick(item) {
      for (var j = 0; j < this.templatesListGroup.length; j++) {
        if (this.templatesListGroup[j].id === item.id) {
          this.templatesListGroup[j].select = true;
          this.tempTemplate = this.templatesListGroup[j].id;
        } else {
          this.templatesListGroup[j].select = false;
        }
      }
    },
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
    },
    selectChange(value) {
      this.newType = value;
      if (value === 3) {
        this.empState = false;
      }

      if (value === 1) {
        this.proRegularDateShow = false;
        this.testDate = true;
        // 根据试用期计算
        if (this.empyleeForm.getFieldValue("joinDate") != null) {
          const newTime = afterTime(this.empyleeForm.getFieldValue("joinDate"), 0);
          setTimeout(() => {
            this.empyleeForm.setFieldsValue({
              turnStraightDate: this.moment(newTime, "YYYY-MM-DD")
            });
          }, 300);
        } else {
          setTimeout(() => {
            this.empyleeForm.setFieldsValue({
              turnStraightDate: undefined
            });
          }, 300);
        }
      } else {
        this.proRegularDateShow = true;
        this.testDate = false;
        if (this.empyleeForm.getFieldValue("joinDate") != null) {
          const newTime = afterTime(this.empyleeForm.getFieldValue("joinDate"), 0);
          setTimeout(() => {
            this.empyleeForm.setFieldsValue({
              turnStraightDate: this.getMoment(newTime)
            });
          }, 300);
        } else {
          setTimeout(() => {
            this.empyleeForm.setFieldsValue({
              turnStraightDate: undefined
            });
          }, 300);
        }
      }
    },
    finishEdit3() {
      if (this.currentItem) {
        // 再次发起或者重新入职
        onJobAgain({ empId: this.currentItem.id, flowId: this.tempTemplate }).then((res) => {
          this.getEmpInfos();
          if (this.tempTemplate) {
            this.isApproval = true;
          } else {
            // 添加成功
            this.isApproval = false;
          }
          this.isCloseMethod2 = true;
        });
      } else {
        this.handleEmpyleeSubmit2();
      }
      this.selectModel = false;
    },
    // 重新入职
    resJoinOrreApproval(e, index) {
      this.currentItem = e;

      // 根据公司查询模板
      getModelList_isUse(this.companyId, "OnJob").then((res) => {
        this.templatesListGroup = [];
        for (var i = 0; i < res.data.length; i++) {
          this.templatesListGroup.push({
            id: res.data[i].id,
            select: false,
            typeName: res.data[i].typeName,
            typeDesc: res.data[i].typeDesc
          });
        }
        if (this.templatesListGroup.length > 0) {
          if (this.templatesListGroup.length === 1) {
            // 默认选中第一条
            this.tempTemplate = this.templatesListGroup[0].id;
            onJobAgain({ empId: this.currentItem.id, flowId: this.tempTemplate }).then((res) => {
              this.getEmpInfos();
              if (this.tempTemplate) {
                this.isApproval = true;
              } else {
                // 添加成功
                this.isApproval = false;
              }
              this.isCloseMethod2 = true;
            });
          } else {
            for (var k = 0; k < this.templatesListGroup.length; k++) {
              if (k === 0) {
                this.templatesListGroup[k].select = true;
              } else {
                this.templatesListGroup[k].select = false;
              }
            }

            // 显示第一条
            this.tempTemplate = this.templatesListGroup[0].id;
            this.selectModel = true;
          }
        } else {
          this.tempTemplate = undefined;
          onJobAgain({ empId: this.currentItem.id }).then((res) => {
            this.getEmpInfos();
            if (this.tempTemplate) {
              this.isApproval = true;
            } else {
              // 添加成功
              this.isApproval = false;
            }
            this.isCloseMethod2 = true;
          });
        }
      });
    },
    handleEmpyleeSubmit2Pre(e) {
      if (this.drawerTitle === "确认到岗") {
        const values = this.saveValueFrom;
        values.companyId = this.companyId;
        values.id = this.joinFormData.id;
        values.approvalStatus = 5;
        values.formalType = values.formalType || 2;
        values.postType = values.postType || 5;
        values.joinDate = values.joinDate || formatDateDefault();
        values.probationDays = values.probationDays || 0;

        if (values.turnStraightDate) {
          if (moment(values.joinDate) > moment(values.turnStraightDate)) {
            values.turnStraightDate = afterTime(values.joinDate, values.probationDays);
          }
        } else {
          values.turnStraightDate = afterTime(values.joinDate, values.probationDays);
        }
        confirmToJoinBatch([values]).then((res) => {
          this.$notification["success"]({
            message: "success",
            description: "提交成功"
          });
          this.visibleDrawer = false;
          this.visibleEmpyleeDrawer2 = false;
          this.visibleConfimSubmit = true;
          this.getTabNumber();
        });
      } else {
        // 添加到入职
        // 根据公司查询模板
        getModelList_isUse(this.companyId, "OnJob").then((res) => {
          this.templatesListGroup = [];
          for (var i = 0; i < res.data.length; i++) {
            this.templatesListGroup.push({
              id: res.data[i].id,
              select: false,
              typeName: res.data[i].typeName,
              typeDesc: res.data[i].typeDesc
            });
          }

          if (this.templatesListGroup.length > 0) {
            if (this.templatesListGroup.length === 1) {
              // 默认选中第一条
              this.tempTemplate = this.templatesListGroup[0].id;
              this.handleEmpyleeSubmit2(e);
            } else {
              for (var m = 0; m < this.templatesListGroup.length; m++) {
                if (m === 0) {
                  this.templatesListGroup[m].select = true;
                } else {
                  this.templatesListGroup[m].select = false;
                }
              }
              this.currentItem = undefined;
              // 显示第一条
              this.tempTemplate = this.templatesListGroup[0].id;
              this.selectModel = true;
            }
          } else {
            this.tempTemplate = undefined;
            this.handleEmpyleeSubmit2(e);
          }
        });
      }
    },
    getShiyongqi() {
      if (this.empyleeForm) {
        return this.empyleeForm.getFieldValue("formalType") === 1; // 试用期
      } else {
        return false;
      }
    },
    handleEmpyleeSubmit2(e) {
      const values = this.saveValueFrom;
      values.companyId = this.companyId;
      values.employType = 1;
      values.status = 1; // 待入职
      if (this.tempTemplate) {
        values.flowId = this.tempTemplate;
      } else {
        values.flowId = "";
      }
      values.joinCityCode = this.joinCityCode;
      values.joinCityName = this.joinCityName;
      values.formalType = values.formalType || 2;
      values.postType = values.postType || 5;
      values.joinDate = values.joinDate || formatDateDefault();
      values.preJoinDate = values.joinDate;
      values.probationDays = values.probationDays || 0;
      values.turnStraightDate = values.turnStraightDate || afterTime(values.joinDate, values.probationDays);
      saveEmpInfoAndRule(values).then((res) => {
        this.getEmpInfos();
        // this.empyleeForm.resetFields();
        this.onCloseDrawer2("visibleEmpyleeDrawer2");
        if (this.tempTemplate) {
          this.isApproval = true;
        } else {
          // 添加成功
          this.isApproval = false;
        }
        this.isCloseMethod2 = true;
        this.getTabNumber();
      });
    },
    addMember() {
      this.proRegularDateShow = false;
      this.testDate = false;
      this.empyleeForm.resetFields();
      this.joinFormData = {};
      this.visibleEmpyleeDrawer2 = true;
      this.drawerTitle = "添加待入职";
    },
    // 按人员状态检索
    handleProgName2(val) {
      delete this.searchForm.status;
      this.searchForm.approvalAndStatus = val;
      this.getEmpInfos(1);
    },
    // 分页查询
    handlePageChange(pagination, filters, sorter) {
      this.pagination2.current = pagination.current;
    },

    // 根据试用期计算预计转正日期
    handleProba(value) {
      const probationDay = this.empyleeForm.getFieldValue("probationDays");
      const newTime = afterTime(this.empyleeForm.getFieldValue("joinDate"), value);
      setTimeout(() => {
        this.empyleeForm.setFieldsValue({
          turnStraightDate: this.moment(newTime, "YYYY-MM-DD")
        });
      }, 300);
    },
    disabledDate2(current) {
      return current && current < moment().startOf("month"); // 月份第一天
    },
    // 离职日期限制
    disabledDate3(current) {
      return current && current < moment().startOf("month"); // 月份第一天
    },
    // 选择参保年份和月份
    onLeaveChange(date, dateString) {
      if (this.isBatchLeaveConfirm) {
        this.batchPreQuitDate = dateString;
      } else {
        this.leaveEmy.preQuitDate = date.valueOf();
      }
      if (this.hasShebao) {
        this.shebaoDate = dateString;
      }
      if (this.hasGjj) {
        this.gongjijinDate = dateString;
      }
      if (this.hasYibao) {
        this.yibaoDate = dateString;
      }
    },
    // 选择参保年份和月份
    onYearMonthChange_SB(date, dateString) {
      this.shebaoDate = dateString;
    },
    onYearMonthChange_GJJ(date, dateString) {
      this.gongjijinDate = dateString;
    },
    onYearMonthChange_YB(date, dateString) {
      this.yibaoDate = dateString;
    },

    handleCancel() {
      this.isCloseMethod = false;

      this.isCloseMethod2 = false;
      this.selectModel = false;
    },
    handleImportChange() {
      // this.handleCancel();

      const url = "/hr/api/v1/empChanges/importExcel";

      const tdata = new FormData();
      tdata.append("companyId", this.companyId);
      tdata.append("file", this.socFile);
      this.spinning = true;
      this.leaveList = [];

      this.$request({
        url,
        method: "post",
        data: tdata
      })
        .then((res) => {
          this.spinning = false;
          if (res.data) {
            this.$message.success("导入成功");
            if (this.piliang_shebaojianyuan) {
              this.piliang_shebaojianyuan = false;
              this.$message.success("减员计划添加成功，请在系统内进行减员确认");
            }
            this.handleCancel();
            this.leaveList = res.data;
            if (this.leaveList.length !== 0) {
              this.$message.success("选择签署离职合同");
              this.$router.push({
                path: "/contract/type",
                query: {
                  leaveList: this.leaveList,
                  fromLeave: true
                }
              });
            } else {
              this.getTabNumber();
            }
          }
        })
        .catch((err) => {
          this.spinning = false;
          console.log("debug log --> ", err);
        });
    },
    onQuerenlizhi(empList) {
      this.isBatchLeaveConfirm = true;
      this.confirmLeaveBatch(empList);
    },
    pilianglizhiModalOk() {
      this.pilianglizhiResultModal = false;
      this.saveLeaveOk();
    },
    finishEdit() {
      if (this.isBatchLeaveConfirm) {
        if (!this.batchPreQuitDate) {
          this.$message.success("请选择离职日期");
          return;
        }
      } else {
        if (this.leaveEmy.preQuitDate === undefined || this.leaveEmy.preQuitDate === undefined) {
          this.$message.success("请选择离职日期");
          return;
        }
      }
      var data = {
        companyId: this.companyId,
        confirmLeaveOfficeDate: this.isBatchLeaveConfirm ? this.batchPreQuitDate : this.leaveEmy.preQuitDate,
        whetherLaunchedContract: this.isHeTong,
        whetherSocDecrease: this.isShebaoJianYuan,
        whetherMeDecrease: this.isYibaoJianYuan,
        whetherPfDecrease: this.isGjjJianYuan,
        whetherDecrease: false,
        serviceCost: this.serviceCost
      };
      if (this.isShebaoJianYuan) {
        const s = this.shebaoDate.split("-");
        data.stopSocYear = s[0];
        data.stopSocMonth = s[1];
        data.whetherDecrease = true;
      }
      if (this.isYibaoJianYuan) {
        const s = this.yibaoDate.split("-");
        data.stopMeYear = s[0];
        data.stopMeMonth = s[1];
        data.whetherDecrease = true;
      }
      if (this.isGjjJianYuan) {
        const s = this.gongjijinDate.split("-");
        data.sealedDateYear = s[0];
        data.sealedDateMonth = s[1];
        data.whetherDecrease = true;
      }
      if (this.isBatchLeaveConfirm) {
        leaveBatchReq({
          ...data,
          whetherLaunchedContract: false,
          empIds: this.leaveEmyList.map((z) => z.id)
        })
          .then((res) => {
            this.isCloseMethod = false;
            this.isBatchLeaveConfirm = false;
            this.pilianglizhiResultModal = true;
            this.pilianglizhiResults = res.data;
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        confimLeave(this.leaveEmy.id, data).then((res) => {
          this.isCloseMethod = false;
          this.leaveList = res.data;
          if (this.isHeTong) {
            this.$message.success("选择签署离职合同");
            this.$router.push({
              path: "/contract/type",
              query: {
                leaveList: this.leaveList,
                fromLeave: true
              }
            });
          } else {
            this.$message.success("离职成功");
            if (this.isShebaoJianYuan || this.isGjjJianYuan || this.isYibaoJianYuan) {
              this.$message.success("减员计划添加成功，请在系统内进行减员确认");
            }
            this.tapChange(this.selectId);
            this.getTabNumber();
          }
        });
      }
    },
    // 是否发起离职合同
    onHtChange(checked) {
      this.isHeTong = checked;
    },
    // 是否进行社保减员
    onJYChange(checked) {
      this.isShebaoJianYuan = checked;
    },
    onJY2Change(checked) {
      this.isGjjJianYuan = checked;
    },
    onJyChange2(checked) {
      this.isYibaoJianYuan = checked;
    },
    handleChangeStaff(e) {
      switch (e.key) {
        case "gmtModified": // 已离职记录
          this.goto("leaveTag");
          break;
        case "gmtCreate": // 导入Excel办理
          this.renliStatus = 0; // 0拖拽，1成功，2失败
          this.spinning = false;
          this.socFile = undefined;
          this.$router.push({ path: `management/import` });
          break;
        case "namePinyin": // 发起离职合同
          this.$router.push({
            path: "/contract/type",
            fromLeave: true
          });
          break;
      }
    },
    beforeUpload1({ file }) {
      this.socFile = file;
    },
    handleChange(info) {
      if (info.file.status === "done") {
        this.$message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === "error") {
        this.$message.error(`${info.file.name} file upload failed.`);
      }
    },
    disabledDate(current) {
      return current < this.moment(this.regularFormData.joinDate);
    },
    handleEmpInfoTableChange(pagination, filters, sorter) {
      this.pagination.current = pagination.current;
      this.EmpListByDep();
    },
    cancelPositionList() {
      this.positonTreeShow = false;
    },
    getPositionList(e) {
      this.positonTreeShow = false;
      this.checkedPostionListGroup = e;
      const arr = [];
      e.forEach((v) => {
        arr.push(v.name);
      });
      this.entryForm.setFieldsValue({
        positionIdList: arr
      });
    },
    search() {
      this.$set(this.managementList.pagination, "current", 1);
      // 预计入职开始时间
      if (!this.searchForm.preJoinDateMoment || this.searchForm.preJoinDateMoment.length === 0) {
        this.searchForm.preJoinDateStart = undefined;
        this.searchForm.preJoinDateEnd = undefined;
      } else {
        this.searchForm.preJoinDateStart = this.moment(this.searchForm.preJoinDateMoment[0]).format("YYYY-MM-DD");
        this.searchForm.preJoinDateEnd = this.moment(this.searchForm.preJoinDateMoment[1]).format("YYYY-MM-DD");
      }
      // 入职开始时间
      if (!this.searchForm.joinDateMoment || this.searchForm.joinDateMoment.length === 0) {
        this.searchForm.joinDateStart = undefined;
        this.searchForm.joinDateEnd = undefined;
      } else {
        this.searchForm.joinDateStart = this.moment(this.searchForm.joinDateMoment[0]).format("YYYY-MM-DD");
        this.searchForm.joinDateEnd = this.moment(this.searchForm.joinDateMoment[1]).format("YYYY-MM-DD");
      }
      // 预计转正时间
      if (!this.searchForm.turnStraightDateMoment || this.searchForm.turnStraightDateMoment.length === 0) {
        this.searchForm.turnStraightDateStart = undefined;
        this.searchForm.turnStraightDateEnd = undefined;
      } else {
        this.searchForm.turnStraightDateStart = this.moment(this.searchForm.turnStraightDateMoment[0]).format("YYYY-MM-DD");
        this.searchForm.turnStraightDateEnd = this.moment(this.searchForm.turnStraightDateMoment[1]).format("YYYY-MM-DD");
      }
      // 预计离职时间
      if (!this.searchForm.leaveDateMoment || this.searchForm.leaveDateMoment.length === 0) {
        this.searchForm.leaveDateStart = undefined;
        this.searchForm.leaveDateEnd = undefined;
      } else {
        this.searchForm.leaveDateStart = this.moment(this.searchForm.leaveDateMoment[0]).format("YYYY-MM-DD");
        this.searchForm.leaveDateEnd = this.moment(this.searchForm.leaveDateMoment[1]).format("YYYY-MM-DD");
      }
      //  调岗开始时间 结束时间
      if (!this.searchForm.transferDateMoment || this.searchForm.transferDateMoment.length === 0) {
        this.searchForm.transferDateStart = undefined;
        this.searchForm.transferDateEnd = undefined;
      } else {
        this.searchForm.transferDateStart = this.moment(this.searchForm.transferDateMoment[0]).format("YYYY-MM-DD");
        this.searchForm.transferDateEnd = this.moment(this.searchForm.transferDateMoment[1]).format("YYYY-MM-DD");
      }
      this.getEmpInfos(1);
    },
    getTabNumber() {
      const data = this.tabList.filter((item) => {
        return item.id === this.selectId;
      });
      this.managementList.title = data[0].tableColumn.filter((i) => (i.align = "left"));
      getEmpInfoCount(this.$store.state.hr.companyId).then((res) => {
        const data = res.data;
        this.tabList.forEach((item, index) => {
          this.$set(this.tabList, index, {
            ...this.tabList[index],
            count: data[this.tabList[index].name]
          });
        });
      });
    },
    getEmpInfos(resetPageNo) {
      this.managementList.loading = true;
      const pagination = this.managementList.pagination;
      const pageNo = resetPageNo || pagination.current;
      const pageSize = pagination.pageSize === 0 ? 10 : pagination.pageSize;
      const target = this.tabList.filter((item) => {
        return item.id === this.selectId;
      });
      const data = {
        pageNo: pageNo === 0 ? 1 : pageNo,
        pageSize: pageSize,
        status: target[0]["status"],
        companyId: this.companyId,
        ...this.searchForm,
        joinFormStatus: this.searchForm.joinFormStatus === "入职登记表是否已提交" ? undefined : this.searchForm.joinFormStatus
      };
      let func;
      switch (this.selectId) {
        case "1":
          // 入职
          func = selectEmpInfoPendingRelation(data);
          this.lzbm = undefined;
          this.zzbm = undefined;
          // 缓存请求参数
          data.selectId = this.selectId;
          this.$setCondition("ygyd_condition", JSON.stringify(data));
          break;
        case "2":
          // 转正
          func = selectEmpInfoToFormalRelation(data);
          this.lzbm = undefined;
          // 缓存请求参数
          data.selectId = this.selectId;
          this.$setCondition("ygyd_condition", JSON.stringify(data));
          break;
        case "3":
          // 在职
          func = selectEmpInfoOnJobRelation(data);
          this.lzbm = undefined;
          this.zzbm = undefined;
          // 缓存请求参数
          data.selectId = this.selectId;
          this.$setCondition("ygyd_condition", JSON.stringify(data));
          break;
        case "4":
          // 离职
          delete data.status;
          func = pageWaitLeave({ ...data, status: 3 });
          this.zzbm = undefined;
          // 缓存请求参数
          data.selectId = this.selectId;
          this.$setCondition("ygyd_condition", JSON.stringify({ ...data, status: 3 }));
          break;
        case "5":
          // 调岗
          delete data.status;
          func = selectEmpInfoTransferRelation(data);
          this.lzbm = undefined;
          this.zzbm = undefined;
          // 缓存请求参数
          data.selectId = this.selectId;
          this.$setCondition("ygyd_condition", JSON.stringify(data));
          break;
      }
      func
        .then((res) => {
          this.selectedRowKeys = [];
          this.managementList.data = res.data && res.data.entities;
          if (res.data && res.data.entities) {
            for (var i = 0; i < res.data.entities.length; i++) {
              if (res.data.entities[i].empChangesListVO) {
                this.managementList.data[i].quitRemarks = res.data.entities[i].empChangesListVO.quitRemarks;
                this.managementList.data[i].quitReason = res.data.entities[i].empChangesListVO.quitReason;
                this.managementList.data[i].preQuitDate = res.data.entities[i].empChangesListVO.preQuitDate; // 离职时间
                this.managementList.data[i].prePositionName = res.data.entities[i].empChangesListVO.prePositionName; // 原岗位
                this.managementList.data[i].currentPositionName = res.data.entities[i].empChangesListVO.currentPositionName; // 变更岗位
                this.managementList.data[i].preDepName = res.data.entities[i].empChangesListVO.preDepName; // 原部门
                this.managementList.data[i].currentDepName = res.data.entities[i].empChangesListVO.currentDepName; // 变更部门
                this.managementList.data[i].adjustmentTime = res.data.entities[i].empChangesListVO.adjustmentDate; // 调岗时间
                this.managementList.data[i].adjustmentReason = res.data.entities[i].empChangesListVO.adjustmentReason; // 调岗原因
              }
            }
            this.managementList.pagination.total = res.data.entityCount; // 共多少条
            this.managementList.pagination.pageSize = res.data.pageSize === 0 ? 10 : res.data.pageSize; // 每页多少条
            this.managementList.pagination.current = res.data.pageNo; // 当前第几页
          } else {
            this.managementList.pagination.total = 0; // 共多少条
            this.managementList.pagination.pageSize = 10; // 每页多少条
            this.managementList.pagination.current = 1; // 当前第几页
          }
        })
        .finally(() => {
          this.managementList.loading = false;
        });
    },

    getEmployeeStatus(status, record, selectId) {
      const approvalStatus = record.approvalStatus;
      let text = "";
      if (selectId === "0") {
        if (status === 1) {
          return "待入职";
        } else if (status === 2) {
          return "入职";
        } else if (status === 3) {
          return "待离职";
        } else if (status === 4) {
          return "离职";
        }
      } else if (selectId === "1") {
        switch (record.approvalAndStatus) {
          case 1:
            return "待入职";
          case 2:
            return "审批中";
          case 3:
            return "审批驳回";
          case 4:
            return "未到岗";
        }
      } else if (selectId === "2") {
        // 转正管理
        text = "待转正";
      } else if (selectId === "3") {
        // 在职管理
        text = "在职";
      } else if (selectId === "4") {
        // 离职管理
        text = "待离职";
        if (status === 4) {
          text = "离职";
        }
      } else if (selectId === "5") {
        // 调岗管理
        text = "待调岗";
      }
      if (approvalStatus === 5) {
        return text;
      } else if (approvalStatus === 1) {
        return "待审批";
      } else if (approvalStatus === 2) {
        return "审批中";
      } else if (approvalStatus === 3) {
        return "审批未通过";
      } else if (approvalStatus === 4) {
        return "审批通过";
      }
    },
    getColor(status, record, selectId) {
      const approvalStatus = record.approvalStatus;
      let text = "";
      if (selectId === "0") {
        if (status === 1) {
          return "#4686FF";
        } else if (status === 2) {
          return "#32CCAA";
        } else if (status === 3) {
          return "#F7B500";
        } else if (status === 4) {
          return "#A6A8B4";
        }
      } else if (selectId === "1") {
        // 在职管理
        switch (record.approvalAndStatus) {
          case 1:
            return "#4686FF";
          case 2:
            return "#6B6BF2";
          case 3:
            return "#FF7085";
          case 4:
            return "#A6A8B4";
        }
      } else if (selectId === "2") {
        // 转正管理
        text = "#4686FF";
      } else if (selectId === "3") {
        // 在职管理
        text = "#32CCAA";
      } else if (selectId === "4") {
        // 离职管理
        text = "#4686FF";
        if (status === 4) {
          text = "#A6A8B4";
        }
      } else if (selectId === "5") {
        // 调岗管理
        text = "#4686FF";
      }
      if (approvalStatus === 5) {
        return text;
      } else if (approvalStatus === 1) {
        return "#4686FF";
      } else if (approvalStatus === 2) {
        return "#4686FF";
      } else if (approvalStatus === 3) {
        return "#FF7085";
      } else if (approvalStatus === 4) {
        return "#32CCAA";
      }
    },
    BatchGetFun() {
      this.$confirm({
        title: "是否进行批量到岗操作?",
        okType: "warning",
        onOk: () => {
          this.drawerTitle = "确认到岗";
          this.getBatchGetFunOpen();
        }
      });
    },
    getBatchGetFunOpen() {
      this.formJoinDate.resetFields();
      this.visibleJoinDate = true;
      this.isBatchJoin = true;
      this.confirmedPostArr = { arr: this.batchArrData };
    },
    getBatchGetFun() {
      const batchArr = [];
      for (var i = 0; i < this.batchArrData.length; i++) {
        batchArr.push({
          id: this.batchArrData[i].id,
          name: this.batchArrData[i].name,
          phone: this.batchArrData[i].phone,
          depIdList: this.batchArrData[i].depName,
          positionIdList: this.batchArrData[i].positionName,
          postType: this.batchArrData[i].postType === 0 ? "" : this.batchArrData[i].postType,
          joinDate: this.getMoment(this.batchArrData[i].joinDate),
          companyId: this.companyId,
          formalType: this.batchArrData[i].formalType,
          preJoinDate: this.batchArrData[i].preJoinDate,
          turnStraightDate: this.batchArrData[i].turnStraightDate,
          approvalStatus: 5
        });
      }
      for (i = 0; i < batchArr.length; i++) {
        if (batchArr[i].postType === 2 || batchArr[i].postType === 3) {
          // 外包或者社保代缴
          batchArr[i].formalType = 2; // 正式
          batchArr[i].preJoinDate = batchArr[i].joinDate;
          batchArr[i].turnStraightDate = batchArr[i].joinDate;
        }
      }
      confirmToJoinBatch(batchArr)
        .then((res) => {
          this.selectedRowKeys = [];
          this.$notification["success"]({
            message: "success",
            description: "提交成功"
          });
          // that.reload();
          this.visibleDrawer = false;
          this.visibleConfimSubmit = true;
          this.getTabNumber();
        })
        .catch((err) => {
          console.log(err.toString());
        });
    },
    handleOkJoinDate(e) {
      delete e.name;
      delete e.arr;
      delete e.addEmpFieldList;
      this.batchArrData = this.batchArrData.map((z) => {
        for (var i in e) {
          z[i] = e[i];
        }

        return z;
      });
      this.batchArrData = this.batchArrData.map((z) => {
        if (z.turnStraightDate < moment(z.joinDate).valueOf()) {
          z.turnStraightDate = moment(z.joinDate).valueOf();
        }
        return z;
      });
      this.visibleJoinDate = false;
      this.isBatchJoin = false;
      this.getBatchGetFun();
    },
    openEmployeesMove(e) {
      // 打开高级筛选
      this.$nextTick(() => {
        this.$refs.employeesMove.showModal(e);
      });
    },
    getNextStep(data, state) {
      this.batchArrData = data;
      if (state === "批量未到岗") {
        this.BatchNoGetFun();
      } else if (state === "批量到岗") {
        this.BatchGetFun();
      } else if (state === "批量离职") {
        this.bulkDeparturesOk(data);
      } else if (state === "批量转正") {
        this.BatchPositive();
      } else if (state === "批量调岗") {
        this.merberBatchDG();
      } else if (state === "批量撤销离职") {
        this.BatchWithdrawal();
      } else if (state === "批量确认调岗") {
        this.BatchConfirmTransfer();
      } else if (state === "批量撤销调岗") {
        this.BatchCancellationTransfer();
      }
    },
    getbatchTransferRegular(values) {
      if (moment().isBefore(values.regularDate)) {
        // console.log("未到期");
        this.iszheng = false;
      } else {
        // console.log("已到期");
        this.iszheng = true;
      }
      const data = {
        regularDate: moment(values.regularDate).format("YYYY-MM-DD"),
        companyId: this.companyId,
        empIdS: this.batchArrData.map((z) => z.id)
      };
      transferRegular(data).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: res.data
        });
        this.formPositive.resetFields();
        this.visiblePositive = false;
        this.visibleSubmit = true;
        this.titleSubmit = "办理转正";
        this.oktext = "确定";
      });
    },
    handleOkPositive() {
      this.formPositive.validateFields((err, values) => {
        if (!err) {
          const len = this.FlowsData && this.FlowsData.length;
          values.companyId = this.companyId;
          values.empIds = [this.regularFormData.id];

          this.flag = 2;

          // 没有审批 穿空 1个传当前值 多个选择
          if (len === 1) {
            values.approFlowId = this.FlowsData[0].id;
            this.getbatchTransferRegular(values);
          } else if (len > 1) {
            this.approvalModal = true;
            this.selectValue = this.FlowsData[0].id;
            this.redisValues = values;
          } else {
            values.approFlowId = "";
            this.getbatchTransferRegular(values);
          }
        }
      });
    },
    handleCancelPositive() {
      this.visiblePositive = false;
    },
    disabledDateRegularDate(current) {
      return current && current < this.disableJoinDate;
    },
    BatchPositive() {
      this.visiblePositive = true;
      const arr = this.batchArrData;
      this.disableJoinDate = this.getDisableDateFun(arr);
    },
    getDisableDateFun(arr) {
      let data = arr[0].joinDate;
      for (var i = 0; i < arr.length - 1; i++) {
        data = data < arr[i + 1].joinDate ? arr[i + 1].joinDate : data;
      }
      return moment(data);
    },
    BatchWithdrawal() {
      this.$confirm({
        title: "是否进行批量撤销离职?",
        okType: "warning",
        onOk: () => {
          // 批量未到岗
          const batchArr = [];
          for (var i = 0; i < this.batchArrData.length; i++) {
            batchArr.push(this.batchArrData[i].id);
          }
          revokeLeaveApi(batchArr).then((res) => {
            this.$notification["success"]({
              message: "success",
              description: "提交成功"
            });
            // that.reload();
            this.visibleDrawer = false;
            // this.visibleConfimSubmit = true;
            this.getTabNumber();
            this.tapChange(this.selectId);
          });
        }
      });
    },
    BatchConfirmTransfer() {
      this.$confirm({
        title: "是否进行批量确认调岗?",
        okType: "warning",
        onOk: () => {
          // 批量未到岗
          const batchArr = this.batchArrData.map((z) => z.id);
          batchConfirmTransferPosition(batchArr).then((res) => {
            this.$notification["success"]({
              message: "success",
              description: "提交成功"
            });
            // that.reload();
            this.visibleDrawer = false;
            this.visibleConfimSubmit = true;
            this.getTabNumber();
          });
        }
      });
    },
    BatchCancellationTransfer() {
      this.$confirm({
        title: "是否进行批量撤销调岗?",
        okType: "warning",
        onOk: () => {
          // 批量未到岗
          const batchArr = this.batchArrData.map((z) => z.id);
          batchRevokeTransferPositionByEmpId(batchArr).then((res) => {
            this.$notification["success"]({
              message: "success",
              description: "提交成功"
            });
            // that.reload();
            this.visibleDrawer = false;
            this.visibleConfimSubmit = true;
            this.getTabNumber();
          });
        }
      });
    },
    BatchNoGetFun() {
      this.$confirm({
        title: "是否进行批量未到岗操作?",
        okType: "warning",
        onOk: () => {
          this.drawerTitle = "确认未到岗";
          // 批量未到岗
          const batchArr = [];
          for (var i = 0; i < this.batchArrData.length; i++) {
            if (this.getEmployeeStatus(this.batchArrData[i].status, this.batchArrData[i], "1") !== "待入职") {
              this.$notification["info"]({
                message: "提醒",
                description: "请选择未到岗员工"
              });
              return;
            }
            batchArr.push(this.batchArrData[i].id);
          }
          confirmToNoJoinBatch(batchArr).then((res) => {
            this.$notification["success"]({
              message: "success",
              description: "提交成功"
            });
            this.getTabNumber();
            this.tapChange(this.selectId);
          });
        }
      });
    },
    onselectValueChange(e) {
      this.selectValue = e.target.value;
    },
    handleApprovalSubmit() {
      var redisValues = this.redisValues;
      redisValues.approFlowId = this.selectValue;
      if (this.flag === 1) {
        this.funcSaveEmpInfoPre(redisValues);
      } else if (this.flag === 2) {
        this.funcTransferRegular(redisValues);
      } else if (this.flag === 3) {
        this.funcLeavePosition(redisValues);
      } else if (this.flag === 4) {
        this.funcTransferJob(redisValues);
      }
    },
    // 获取某公司离职可用的的所有审批流程
    leavingFlowsFunc() {
      leavingFlows(this.$store.state.hr.companyId).then((res) => {
        this.FlowsData = res.data;
        this.leaveForm.validateFields((err, values) => {
          if (!err) {
            const len = this.FlowsData && this.FlowsData.length;
            values.companyId = this.companyId;
            values.empIds = this.openBulkDepartures ? this.selectedRowKeysModelIds : this.selectedRowKeys;
            values.quitReason = values.quitReason.join(",");
            this.flag = 3;
            // 没有审批 穿空 1个传当前值 多个选择
            if (len === 1) {
              values.approFlowId = this.FlowsData[0].id;
              this.funcLeavePosition(values);
            } else if (len > 1) {
              this.approvalModal = true;
              this.selectValue = this.FlowsData[0].id;
              this.redisValues = values;
            } else {
              values.approFlowId = "";
              this.funcLeavePosition(values);
            }
          }
        });
      });
    },
    // 获取某公司调岗可用的的所有审批流程
    transferDutyFlowsFunc() {
      transferDutyFlows(this.$store.state.hr.companyId).then((res) => {
        this.FlowsData = res.data;
      });
    },
    // 获取某公司转正可用的的所有审批流程
    turnStraightFlowsFunc() {
      turnStraightFlows(this.$store.state.hr.companyId).then((res) => {
        this.FlowsData = res.data;
      });
    },
    // 获取某公司入职可用的的所有审批流程
    onJobFlowsFunc() {
      onJobFlows(this.$store.state.hr.companyId).then((res) => {
        this.FlowsData = res.data;
      });
    },
    revokeLeave(e) {
      revokeLeaveApi([e.id]).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "操作成功"
        });
        // this.reload()
        this.tapChange(this.selectId);
        this.getTabNumber();
      });
    },
    confimTransferPosition(e) {
      debugger;
      confimTransferPositionApi(e.id).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "操作成功"
        });
        this.tapChange(this.selectId);
        this.getTabNumber();
      });
    },
    revokeTransferPosition(e) {
      revokeTransferPositionApi([e.id]).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "操作成功"
        });
        this.tapChange(this.selectId);
        this.getTabNumber();
      });
    },
    // 确定离职
    confirmLeaveBatch(lst) {
      this.serviceCost = undefined;
      this.isCloseMethod = true;
      this.leaveEmyList = lst;
      this.hasShebao = true;
      this.hasYibao = true;
      this.hasGjj = true;
      this.isShebaoJianYuan = false;
      this.isYibaoJianYuan = false;
      this.isGjjJianYuan = false;
      this.disableJoinDate = this.getDisableDateFun(lst);
    },
    // 确定离职
    confirmLeave(e) {
      this.isBatchLeaveConfirm = false;
      this.serviceCost = undefined;
      this.isCloseMethod = true;
      this.leaveEmy = e;
      this.hasShebao = false;
      this.hasYibao = false;
      this.hasGjj = false;
      this.isShebaoJianYuan = false;
      this.isYibaoJianYuan = false;
      this.isGjjJianYuan = false;
      this.disableJoinDate = moment(e.joinDate);
      findEmpHaveSocInfo(e.id).then((res) => {
        if (res.data.haveSoc) {
          this.hasShebao = true;
        }
        if (res.data.havePf) {
          this.hasGjj = true;
        }
        if (res.data.haveMe) {
          this.hasYibao = true;
        }
      });
    },
    openUser(e) {
      empRegisterAccount(e).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "开通成功"
        });
        this.tapChange(this.selectId);
        this.getTabNumber();
      });
    },
    getMoment(date) {
      return date ? this.moment(date) : null;
    },
    // button group start
    toPage(link) {
      this.$router.push({
        path: link
      });
    },
    goto(tag) {
      this.nameDisabled = false;
      if (tag === "moveTag") {
        this.$router.push({
          path: "/staff/moveTag",
          query: { selectId: this.selectId, moveTag: this.moveTag }
        });
        return;
      } else if (tag === "leaveTag") {
        this.$router.push({
          path: "/staff/LeaveList",
          query: { selectId: this.selectId, moveTag: this.moveTag }
        });
        return;
      }
      this[tag] = true;
      this.$nextTick(() => {
        this.moveForm.resetFields();
      });
    },
    hideList(tag) {
      this[tag] = false;
    },
    // button group end
    // 办理入职 start
    onJoinEmp() {
      this.tapChange(this.selectId);
      this.getTabNumber();

      if (this.oktext === "确定") {
        this.visibleSubmit = false;
        this.approvalModal = false;
        // this.reload();

        return;
      }
      this.visibleSubmit = false;
      this.approvalModal = false;
      this.entryForm.resetFields();
      this.visibleDrawer = true;
      // 获取审批流程
      this.onJobFlowsFunc();
    },
    merberLeave() {
      this.visibleLeaveDrawer = true;
      this.nameDisable = false;
      this.$nextTick(() => {
        this.leaveForm.resetFields();
      });
    },
    bulkDeparturesOk(arr) {
      this.openBulkDepartures = true;
      this.disableJoinDate = this.getDisableDateFun(arr);
      this.selectedRowKeysModelIds = arr.map((z) => z.id);
      const tmep_name = arr.map((z) => z.name);
      this.nameDisable = true;
      this.visibleLeaveDrawer = true;
      this.$nextTick(() => {
        this.leaveForm.resetFields();
      });
      setTimeout(() => {
        this.leaveForm.setFieldsValue({
          name: tmep_name + ""
        });
      }, 300);
      this.leavingFlowsFunc();
    },
    // 批量离职
    merberBatchLZ(e) {
      this.$refs.BatchLeaveFilterSelect.showModal(e);
    },
    makeLeave(e) {
      this.disableJoinDate = moment(e.joinDate);
      this.openBulkDepartures = false;
      this.nameDisable = true;
      this.visibleLeaveDrawer = true;
      this.selectedRowKeys = [e.id];
      this.$nextTick(() => {
        this.leaveForm.resetFields();
      });
      setTimeout(() => {
        this.leaveForm.setFieldsValue({
          name: e.name
        });
      }, 300);
      this.leavingFlowsFunc();
    },
    onChangeLeaveModal(checkedValues) {
      this.checkedListGroup = checkedValues;
    },
    confirmLeaveModal() {
      this.visibleLeaveModal = false;
      this.leaveForm.setFieldsValue({
        quitReason: this.checkedListGroup
      });
    },
    handleCancelLeaveModal() {
      this.visibleLeaveModal = false;
      // this.flag = false
    },
    LeaveChange(tag) {
      this.checkedListGroup = tag;
    },
    showLeaveModal() {
      this.checkedListGroup = [];
      this.visibleLeaveModal = true;
      this.$refs.selectModal.blur();
    },
    // 调岗
    handleMoveSubmit(e) {
      // var that = this;
      e.preventDefault();
      this.moveForm.validateFields((err, values) => {
        if (!err) {
          const len = this.FlowsData && this.FlowsData.length;

          values.companyId = this.companyId;
          values.empIds = this.batchArrData.map((z) => z.id);
          this.flag = 4;

          // 没有审批 穿空 1个传当前值 多个选择
          if (len === 1) {
            values.approFlowId = this.FlowsData[0].id;
            this.funcTransferJob(values);
          } else if (len > 1) {
            this.approvalModal = true;
            this.selectValue = this.FlowsData[0].id;
            this.redisValues = values;
          } else {
            values.approFlowId = "";
            this.funcTransferJob(values);
          }
        }
      });
    },
    funcTransferJob(values) {
      transferJob(values).then((res) => {
        this.hideList("visibleMoveDrawer");
        this.visibleSubmit = true;

        this.oktext = "确定";
        this.titleSubmit = "办理调岗";
      });
    },
    handleLeaveSubmit(e) {
      this.leavingFlowsFunc();
      e.preventDefault();
    },
    // 下载模板
    download() {
      const token = this.$store.state.auth.token;
      let params = {};
      params = {
        templateName: "batchLeaveOfficeImportTemplate.xlsm"
      };

      axios({
        url: ` /hr/api/v1/excel/template/download`,
        params,
        paramsSerializer: (param) => {
          return qs.stringify(param, { indices: false });
        },
        method: "get",
        responseType: "blob",
        headers: {
          token: token
        }
      })
        .then((res) => {
          const link = document.createElement("a");
          const blob = new Blob([res.data], {
            type: "multipart/form-data"
          });
          link.style.display = "none";
          link.href = URL.createObjectURL(blob);
          link.setAttribute("download", "批量确认离职模板.xlsm");
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
        })
        .catch((err) => {
          console.log("debug log --> ", err);
        });
    },
    funcLeavePosition(values) {
      leavePosition(values).then((res) => {
        this.onCloseDrawer("Leave");
        this.visibleSubmit = true;
        this.oktext = "确定";
        this.titleSubmit = "办理离职";
      });
    },
    showMeberDialog(e) {
      e.stopPropagation();
      this.nameOrPhoneOrEmail = "";
      this.selectedTempRowKeys = this.selectedRowKeys;
      // this.selectedRowKeys = this.selectedTempRowKeys;
      //
      this.visibleMerber = true;
      this.adjustButtonDisabled = true;
      this.pagination.current = 1;
      this.$refs.nameModal.blur();
      this.leaveForm.setFieldsValue({ preQuitDate: null });
      this.EmpListByDep();
    },
    selectEmp() {
      this.pagination.current = 1;
      this.EmpListByDep();
    },
    EmpListByDep() {
      const data = {
        companyId: this.companyId,
        pageNo: this.pagination.current,
        pageSize: this.pagination.pageSize,
        // parentId: 0,
        nameOrPhoneOrEmail: this.nameOrPhoneOrEmail
      };
      selectEmpInfoListForLeave(data).then((res) => {
        if (res.data === null) {
          this.pagination.total = 0; // 共多少条
          this.pagination.current = 1; // 当前第几页
          this.empInfoList = [];
        } else {
          this.pagination.total = res.data.entityCount; // 共多少条
          this.pagination.pageSize = res.data.pageSize === 0 ? 10 : res.data.pageSize; // 每页多少条
          this.pagination.current = res.data.pageNo; // 当前第几页
          this.empInfoList = res.data.entities;
        }
      });
    },
    adjustEmp() {
      this.selectedRowKeys = this.selectedTempRowKeys;
      const selectObj = this.empInfoList.filter((item) => {
        return item.id === this.selectedRowKeys[0];
      })[0];
      this.disableJoinDate = moment(selectObj.joinDate);
      if (this.selectId === "4") {
        this.leaveForm.setFieldsValue({
          name: selectObj.name
        });
      } else if (this.selectId === "5") {
        this.moveForm.setFieldsValue({
          name: selectObj.name
        });
        this.batchArrData = this.selectedTempRowKeys.map((z) => {
          return {
            id: z
          };
        });
      }
      this.visibleMerber = false;
    },
    selectionChange(selection) {
      this.selectedTempRowKeys = [selection.pop()];
      this.adjustButtonDisabled = this.selectedTempRowKeys.length === 0;
    },
    handleSubmit(e) {
      e.preventDefault();
      this.entryForm.validateFields((err, values) => {
        if (!err) {
          const len = this.FlowsData && this.FlowsData.length;
          values.companyId = this.companyId;
          values.approFlowId = this.approFlowId;
          values.preJoinDep = values.depIdList;
          values.preJoinPosition = values.positionIdList;
          this.flag = 1;
          // 没有审批 穿空 1个传当前值 多个选择
          if (len === 1) {
            values.approFlowId = this.FlowsData[0].id;
            this.funcSaveEmpInfoPre(values);
          } else if (len > 1) {
            this.approvalModal = true;
            this.selectValue = this.FlowsData[0].id;
            this.redisValues = values;
          } else {
            values.approFlowId = "";
            this.funcSaveEmpInfoPre(values);
          }
        }
      });
    },
    funcSaveEmpInfoPre(values) {
      var that = this;
      saveEmpInfoPre(values).then((res) => {
        that.onCloseDrawer("");
        that.visibleSubmit = true;
        this.oktext = "继续办理";
        that.titleSubmit = "办理入职";
      });
    },
    // 确认未到岗
    handleJoinSubmit() {
      confirmToNoJoinBatch([this.joinFormData.id]).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "提交成功"
        });
        this.visibleDrawer = false;
        this.visibleConfimSubmit = true;
        this.getTabNumber();
      });
    },
    handleRegularSubmit(e) {
      // var that = this;
      e.preventDefault();
      this.regularForm.validateFields((err, values) => {
        if (!err) {
          // start
          const len = this.FlowsData && this.FlowsData.length;
          values.companyId = this.companyId;
          values.empIds = [this.regularFormData.id];
          this.flag = 2;
          // 没有审批 穿空 1个传当前值 多个选择
          if (len === 1) {
            values.approFlowId = this.FlowsData[0].id;
            this.funcTransferRegular(values);
          } else if (len > 1) {
            this.approvalModal = true;
            this.selectValue = this.FlowsData[0].id;
            this.redisValues = values;
          } else {
            values.approFlowId = "";
            this.funcTransferRegular(values);
          }
          // end
        }
      });
    },
    funcTransferRegular(values) {
      if (moment().isBefore(values.regularDate)) {
        //
        // console.log("未到期");
        this.iszheng = false;
      } else {
        // console.log("已到期");
        this.iszheng = true;
      }
      transferRegular(values).then((res) => {
        this.$notification["success"]({
          message: "success",
          description: "提交成功"
        });
        this.visibleSubmit = true;
        this.titleSubmit = "办理转正";
        this.oktext = "确定";

        this.visibleRegularDrawer = false;
      });
    },
    employTypeChange(val) {
      this.employType = val;
    },
    confirmJoin(e) {
      this.drawerTitle = "确认到岗";
      getEmpField({ empId: e.id, moduleType: "onJob" }).then((res) => {
        const data = res.data.data;
        const additionalFieldVOList = res.data.additionalFieldVOList.reduce(function (res, key) {
          res[key.fieldId] = key.content;
          return res;
        }, {});
        const data1 = Object.assign(res.data.empInfoVO, data, additionalFieldVOList);
        this.joinFormData = Object.assign(data1, { id: e.id });
        this.visibleEmpyleeDrawer2 = true;
      });
      this.$nextTick(() => {
        this.empyleeForm.setFieldsValue({
          id: e.id,
          name: e.name,
          phone: e.phone,
          idCard: e.idCard,
          formalType: e.formalType,
          probationDays: e.probationDays,
          turnStraightDate: this.getMoment(e.turnStraightDate),
          channelId: e.channelId,
          depIdList: e.depName,
          positionIdList: e.positionName,
          postType: e.postType === 0 ? "" : e.postType,
          joinDate: this.getMoment(e.joinDate),
          remark: e?.remark || null
        });
        this.handleProba(e.probationDays);
      });
      this.selectChange(e.formalType);
    },
    // 未到岗
    noConfirmJoin(e) {
      // this.visibleJoinDrawer = true;
      this.joinFormData = e;
      this.drawerTitle = "确认未到岗";
      this.handleJoinSubmit();
    },
    // 办理入职 end
    onCloseDrawer(str) {
      this["visible" + str + "Drawer"] = false;
    },
    onCloseDrawer2(tag) {
      this[tag] = false;
    },
    onCloseJoinDrawer() {
      this.visibleJoinDrawer = false;
    },
    onCloseRegularDrawer() {
      this.visibleRegularDrawer = false;
    },
    // 转正点击
    confirmRegular(e) {
      this.visibleRegularDrawer = true;
      this.regularFormData = e;
      this.disableJoinDate = moment(e.joinDate);
      this.turnStraightFlowsFunc();
    },
    handleCancelSubmit(tag) {
      // this.reload()
      this[tag] = false;
      this.approvalModal = false;
      this.visibleJoinDrawer = false;
      this.tapChange(this.selectId);
      this.getTabNumber();
    },
    // 取消筛选
    cancelSelect() {
      this.selectBox = false;
      // 清空条件
      this.nameOrPhone = "";
      this.joinFormStatus = undefined;
      this.defaultTableFormValue = "入职登记表是否已提交";
      this.preJoinDateEnd = "";
      this.preJoinDateStart = "";
      this.sex = "";
      this.employType = "";
      this.formalType = "";
      this.depId = "";
      this.sexvalue = "";
      this.employTypevalue = "";
      this.formalTypevalue = "";
      this.depIdvalue = "";

      this.getEmpInfos();
    },
    preventDefault(x, y) {
      this[x] = "";
      if (y) {
        this[y] = "";
      }
      this[x + "value"] = "";
      this.getEmpInfos();

      if (
        this.sex === "" &&
        this.employType === "" &&
        this.formalType === "" &&
        this.depId === "" &&
        this.nameOrPhone === "" &&
        this.joinFormStatus === "" &&
        this.preJoinDateEnd === "" &&
        this.preJoinDateStart === ""
      ) {
        this.selectBox = false;
      }
    },
    tapChange(id) {
      this.managementList.pagination.current = 1;
      this.selectId = id;

      this.hideList("leaveTag");
      this.hideList("moveTag");
      this.searchForm = {};
      const data = this.tabList.filter((item) => {
        return item.id === this.selectId;
      });
      this.managementList.title = data[0].tableColumn;

      this.getEmpInfos();
    },
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys;
    },

    leave(record) {
      this.$router.push({
        path: "/staff/leave",
        query: {
          empInfoId: record.id
        }
      });
    },

    // 批量调岗
    merberBatchDG() {
      let tmep_name = "";
      for (var i = 0; i < this.batchArrData.length; i++) {
        tmep_name += this.batchArrData[i].name + ",";
      }

      this.nameDisabled = true;
      this.visibleMoveDrawer = true;
      this.$nextTick(() => {
        this.moveForm.resetFields();
      });
      // this.selectedRowKeys = [e.id];

      setTimeout(() => {
        this.moveForm.setFieldsValue({
          name: tmep_name
        });
      }, 300);
      this.transferDutyFlowsFunc();
    },
    makeTransfer(e) {
      this.nameDisabled = true;
      this.visibleMoveDrawer = true;
      this.$nextTick(() => {
        this.moveForm.resetFields();
      });
      this.batchArrData = [{ id: e.id }];
      setTimeout(() => {
        this.moveForm.setFieldsValue({
          name: e.name
        });
      }, 300);
      this.transferDutyFlowsFunc();
    },
    select: function (e, x) {
      // 清空条件
      this.selectBox = true;
      this[x + "value"] = e.label;

      this.$set(this.managementList.pagination, "current", 1);

      this.getEmpInfos(1);
    },
    detail: function (row, type) {
      const target = this.tabList.filter((item) => {
        return item.id === this.selectId;
      });
      const searchData = {
        queryType: type,
        status: target[0]["status"],
        companyId: this.companyId,
        ...this.searchForm,
        joinFormStatus: this.searchForm.joinFormStatus === "入职登记表是否已提交" ? undefined : this.searchForm.joinFormStatus
      };
      this.$router.push({
        path: "/staff/detail",
        query: {
          id: row.id,
          userId: row.userId,
          prevpage: location.hash.slice(1)
        }
      });
    },
    handleTableChange(pagination, filters, sorter) {
      console.log("bbbbbbb" + pagination.current);
      this.managementList.pagination.current = pagination.current;
      this.managementList.pagination.pageSize = pagination.pageSize;
      this.getEmpInfos();
    },
    tree(array, childKey, onlyLastChild) {
      if (array === null || array.length < 1) {
        return [];
      }
      array.map((item, index) => {
        item["value"] = item.id;
        item["key"] = item.id;
        item["label"] = item.name;
        item["children"] = item[childKey];

        if (item.children) {
          item["disabled"] = onlyLastChild;
          this.tree(item.children, childKey, onlyLastChild);
        }
      });
      return array;
    },
    tree1(array, childKey, onlyLastChild) {
      if (array === null || array.length < 1) {
        return [];
      }
      array.map((item, index) => {
        item["value"] = item.id;
        item["key"] = item.id;
        item["label"] = item.name;
        item["children"] = item[childKey];
        if (item.leave !== 3) {
          item["disabled"] = onlyLastChild;
        }

        if (item.children) {
          this.tree(item.children, childKey, onlyLastChild);
        }
      });
      return array;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "./styles/index.scss";
.headerBox {
  width: 100%;
  height: 100px;
  background: rgba(255, 255, 255, 0);
  box-shadow: 0px 6px 16px 8px rgba(0, 0, 0, 0.03), 0px 4px 8px 0px rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  .headerBoxItem {
    width: 20%;
    padding-top: 26px;
    height: 100%;
    display: inline-block;
    cursor: pointer;
  }
  .headerBoxItem:hover {
    background: #f4f6fa;
  }
  .headerBoxItemHei26 {
    height: 48px;
    width: 100%;
    border-right: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
  }
  .headerBoxItem:last-child .headerBoxItemHei26 {
    border-right: 0px solid #e8e8e8;
  }
  .headerBoxItemHeiImg {
    width: 32px;
    height: 32px;
    margin-right: 16px;
  }
  .headerBoxItemHeiBox {
    display: flex;
    align-items: center;
    padding-left: 24px;
  }
  .cola6a {
    color: #a6a8b4;
    font-size: 14px;
    font-family: SourceHanSansCN-Regular, SourceHanSansCN;
  }
  .col55565D {
    font-size: 18px;
    font-family: DINAlternate-Bold, DINAlternate;
    font-weight: bold;
    color: #55565d;
    margin-top: 12px;
  }
  .backF4F {
    background: #f4f6fa;
  }
}
</style>
